Skip to content

Commit

Permalink
fix(build): upgrade to rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Sep 1, 2019
1 parent bd7b9f1 commit 5fbe772
Show file tree
Hide file tree
Showing 7 changed files with 584 additions and 2,150 deletions.
62 changes: 24 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ export NODE_VERSION := $(shell node -v)
export RUNNER_VERSION := $(CI_RUNNER_VERSION)
export WEBPACK_VERSION := $(shell $(NODE_BIN)/webpack -v)

all: build run-terminal
all: build test run-terminal
@echo Success!

clean: ## clean up the target directory
clean: ## clean up everything added by the default target
clean: clean-deps clean-target

clean-deps: ## clean up the node_modules directory
rm -rf node_modules

clean-target: ## clean up the target directory
rm -rf $(TARGET_PATH)

configure: ## create the target directory and other files not in git
Expand All @@ -81,57 +87,37 @@ todo:
@grep "as any" -r src/ test/ || true
@echo ""

# build targets
# Build targets
build: ## builds, bundles, and tests the application
build: build-fast

build-cover: ## builds, bundles, and tests the application with code coverage
build-cover: configure node_modules bundle-fast test-cover

build-fast: ## builds, bundles, and tests the application
build-fast: configure node_modules bundle-fast test-fast

build-strict: ## builds, bundles, and tests the application with type checks and extra warnings (slow)
build-strict: configure node_modules bundle-strict test-cover
build: build-bundle build-docs

# bundle targets
bundle: bundle-fast ## build the distributable version of the application
build-bundle: node_modules
$(NODE_BIN)/rollup --config $(CONFIG_PATH)/rollup.js

bundle-fast: ## bundle the application without type checking (faster)
TEST_CHECK=false $(NODE_BIN)/webpack $(BUNDLE_OPTS)
build-docs: ## generate html docs
$(NODE_BIN)/api-extractor run --config $(CONFIG_PATH)/api-extractor.json --local -v
$(NODE_BIN)/api-documenter markdown -i $(TARGET_PATH)/api -o $(DOCS_PATH)/api

bundle-strict: ## bundle the application with full type checking (stricter)
TEST_CHECK=true $(NODE_BIN)/webpack $(BUNDLE_OPTS)
test: ## run mocha unit tests
test: test-cover

bundle-stats: ## bundle the application and print statistics
TEST_CHECK=false $(NODE_BIN)/webpack $(BUNDLE_OPTS) --json --profile |\
tee "$(TARGET_PATH)/webpack.json"

bundle-watch: ## bundle the application and watch for changes
TEST_CHECK=false $(NODE_BIN)/webpack $(BUNDLE_OPTS) --watch

bundle-docs: ## generate html docs
$(NODE_BIN)/typedoc $(DOCS_OPTS)

# test targets
test: test-fast ## run mocha unit tests
test-check: ## run mocha unit tests with coverage reports
$(NODE_BIN)/nyc $(COVER_OPTS) $(NODE_BIN)/mocha $(MOCHA_OPTS) $(TARGET_PATH)/test.js

test-cover: ## run mocha unit tests with coverage reports
$(NODE_BIN)/nyc $(COVER_OPTS) $(NODE_BIN)/mocha $(MOCHA_OPTS) $(TARGET_PATH)/test-bundle.js
test-cover: test-check
sed -i $(TARGET_PATH)/coverage/lcov.info \
-e '/external ".*"$$/,/end_of_record/d' \
-e '/ sync$$/,/end_of_record/d' \
-e '/external /,/end_of_record/d' \
-e '/test sync/,/end_of_record/d' \
-e '/node_modules/,/end_of_record/d' \
-e '/bootstrap$$/,/end_of_record/d'
-e '/bootstrap$$/,/end_of_record/d' \
-e '/universalModuleDefinition/,/end_of_record/d'
sed -n '/^SF/,$$p' -i $(TARGET_PATH)/coverage/lcov.info
sed '1s;^;TN:\n;' -i $(TARGET_PATH)/coverage/lcov.info

test-fast: ## run mocha unit tests with coverage reports
$(NODE_BIN)/mocha $(MOCHA_OPTS) $(TARGET_PATH)/test-bundle.js

test-watch:
$(NODE_BIN)/mocha $(MOCHA_OPTS) --watch $(TARGET_PATH)/test-bundle.js
$(NODE_BIN)/nyc $(COVER_OPTS) $(NODE_BIN)/mocha $(MOCHA_OPTS) --watch $(TARGET_PATH)/test-bundle.js

yarn-install: ## install dependencies from package and lock file
yarn
Expand Down
82 changes: 82 additions & 0 deletions config/rollup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import multiEntry from 'rollup-plugin-multi-entry';
import replace from 'rollup-plugin-replace';
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';

const metadata = require('../package.json');

const bundle = {
external: [
'async_hooks',
],
input: [
'src/index.ts',
'test/harness.ts',
'test/**/Test*.ts',
],
manualChunks(id) {
if (id.includes('/test/') || id.includes('/node_modules/')) {
return 'test';
}

if (id.includes('/src/')) {
return 'main';
}

return 'index';
},
output: {
dir: 'out/',
chunkFileNames: '[name].js',
entryFileNames: 'entry-[name].js',
format: 'cjs',
sourcemap: true,
banner: () => {
return '\n';
},
},
plugins: [
multiEntry(),
json(),
replace({
delimiters: ['{{ ', ' }}'],
values: {
APP_NAME: metadata.name,
APP_VERSION: metadata.version,
BUILD_JOB: process.env['CI_JOB_ID'],
BUILD_RUNNER: process.env['CI_RUNNER_DESCRIPTION'],
GIT_BRANCH: process.env['CI_COMMIT_REF_SLUG'],
GIT_COMMIT: process.env['CI_COMMIT_SHA'],
NODE_VERSION: process.env['NODE_VERSION'],
},
}),
resolve({
preferBuiltins: true,
}),
commonjs({
namedExports: {
'node_modules/chai/index.js': [
'expect',
'use',
],
'node_modules/lodash/lodash.js': [
'isFunction',
'isMap',
'isNil',
'isString',
'kebabCase',
],
},
}),
typescript({
cacheRoot: 'out/cache/rts2',
rollupCommonJSResolveHack: true,
}),
],
};

export default [
bundle,
];
6 changes: 2 additions & 4 deletions config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": false,
"baseUrl": "../",
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
Expand All @@ -17,7 +16,6 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"paths": {},
"sourceMap": true,
"strict": true,
"strictBindCallApply": true,
Expand All @@ -38,7 +36,7 @@
]
},
"exclude": [
"node_modules"
"../node_modules"
],
"include": [
"../src/**/*",
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
},
"devDependencies": {
"@kubernetes/client-node": "0.10.2",
"@microsoft/api-documenter": "^7.3.17",
"@microsoft/api-extractor": "^7.3.9",
"@octokit/rest": "16.28.4",
"@slack/client": "5.0.1",
"@types/bunyan": "1.8.6",
Expand Down Expand Up @@ -43,7 +45,6 @@
"@types/ws": "6.0.1",
"@types/yargs-parser": "13.0.0",
"ajv": "6.10.2",
"awesome-typescript-loader": "5.2.1",
"aws-sdk": "2.493.0",
"bufferutil": "4.0.1",
"bunyan": "1.8.12",
Expand All @@ -56,11 +57,9 @@
"express-graphql": "0.9.0",
"graphql": "14.4.2",
"handlebars": "4.1.2",
"hard-source-webpack-plugin": "0.13.1",
"i18next": "17.0.6",
"ineeda": "0.12.0-alpha.0",
"js-yaml": "3.13.1",
"json-loader": "0.5.7",
"jsonwebtoken": "8.5.1",
"lodash": "4.17.14",
"mathjs": "5.10.3",
Expand All @@ -75,6 +74,13 @@
"request": "2.88.0",
"request-promise": "4.2.4",
"request-promise-native": "1.0.7",
"rollup": "^1.20.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-multi-entry": "^2.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-typescript2": "^0.24.0",
"rxjs": "6.5.2",
"rxjs-tslint-rules": "4.24.3",
"shiro-trie": "0.4.8",
Expand All @@ -87,23 +93,18 @@
"tslint-clean-code": "0.2.9",
"tslint-consistent-codestyle": "1.15.1",
"tslint-etc": "1.5.6",
"tslint-loader": "3.6.0",
"tslint-microsoft-contrib": "6.2.0",
"tslint-sonarts": "1.9.0",
"typedoc": "0.14.2",
"typeorm": "0.2.18",
"typescript": "3.5.3",
"utf-8-validate": "5.0.2",
"uuid": "3.3.2",
"webpack": "4.35.3",
"webpack-bundle-analyzer": "3.3.2",
"webpack-cli": "3.3.6",
"ws": "7.1.0",
"yaml-loader": "0.5.0",
"yargs-parser": "13.1.1"
},
"resolutions": {
"**/lodash": "4.17.14",
"**/lodash": "4.17.15",
"**/@types/graphql": "14.2.2"
},
"nyc": {
Expand Down
3 changes: 3 additions & 0 deletions src/module/BotModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export interface BotModuleOptions {
}

export class BotModule extends BaseModule {
public container?: Container;
public logger?: Logger;

protected bot?: Bot;
protected metrics?: Registry;
protected schema?: Schema;
Expand Down
2 changes: 0 additions & 2 deletions src/transform/BaseTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export abstract class BaseTransform<TData extends TransformData> extends BotServ

protected mergeScope(entity: FilterValue, data: TemplateScope): TemplateScope {
const ed = entityData(entity);
console.log('===marker');
console.dir(ed);
const map = pushMergeMap(ed, makeMap(data));
return makeDict(map);
}
Expand Down
Loading

0 comments on commit 5fbe772

Please sign in to comment.