From a274e25c34a3648fbde4187c931f12a0757b380b Mon Sep 17 00:00:00 2001 From: Tiago Schenkel Date: Tue, 24 Jul 2018 22:59:30 +0200 Subject: [PATCH 1/8] ignore dev folder --- .gitignore | 1 + .npmignore | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5dcaed0..e5dbfb1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea build +dev lib node_modules typings diff --git a/.npmignore b/.npmignore index 6532bbb..a9ccd0c 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,7 @@ /.idea /.vscode /coverage +/dev /dist /docs /lib/test From 6ac43560fe54508894caabf2c19a1d40a9cd0f2b Mon Sep 17 00:00:00 2001 From: Tiago Schenkel Date: Tue, 24 Jul 2018 22:59:48 +0200 Subject: [PATCH 2/8] update tsconfig settings --- tsconfig.json | 9 ++++++--- tsconfig.test.json | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 8b61ecc..37aae08 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,10 +6,13 @@ "module": "commonjs", "moduleResolution": "node", "declaration": true, - "noImplicitAny": false, - "sourceMap": true, "experimentalDecorators": true, - "emitDecoratorMetadata": true + "emitDecoratorMetadata": true, + "noImplicitAny": true, + "noUnusedParameters": false, + "noUnusedLocals": true, + "removeComments": true, + "sourceMap": false }, "include": [ "./src/**/*.ts" diff --git a/tsconfig.test.json b/tsconfig.test.json index 280a8ce..4f739e2 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -6,10 +6,13 @@ "module": "commonjs", "moduleResolution": "node", "declaration": true, - "noImplicitAny": false, - "sourceMap": true, "experimentalDecorators": true, - "emitDecoratorMetadata": true + "emitDecoratorMetadata": true, + "noImplicitAny": true, + "noUnusedParameters": false, + "noUnusedLocals": true, + "removeComments": true, + "sourceMap": true }, "include": [ "./src/**/*.ts", From 433dfa289facdfc564f8f68d649bcf839cb5a8ec Mon Sep 17 00:00:00 2001 From: Tiago Schenkel Date: Tue, 24 Jul 2018 23:02:04 +0200 Subject: [PATCH 3/8] add compile scripts --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 845e40f..2794c90 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "autoformat": "prettier --config .prettierrc --write {src,test}/**/*.ts", "tslint-check": "tslint-config-prettier-check ./tslint.json", "clean-up": "rimraf .nyc_output && rimraf coverage && rimraf lib", - "prepare": "npm run clean-up && tsc -d", + "compile:src": "tsc -d", + "compile:test": "tsc -p tsconfig.test.json -d", + "prepare": "npm run clean-up && compile:src", "prepublishOnly": "publish-please guard", "publish-please": "npm run autoformat && npm run clean-up && npm run test && publish-please" }, From 9297caa1f4670b943c77b67ce0b03a1d68943656 Mon Sep 17 00:00:00 2001 From: Tiago Schenkel Date: Tue, 24 Jul 2018 23:02:24 +0200 Subject: [PATCH 4/8] update webpack config --- karma.conf.js | 47 ++++++++++++++++++++++------------------------- webpack.config.js | 45 ++++++++++++++++++++++++++++----------------- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 6b617dd..986ea2c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -3,35 +3,20 @@ process.env.NODE_ENV = 'test'; const webpack = require("webpack"); const path = require("path"); -const webpackConfig = require('./webpack.config.js')({ isTest: true }); +const webpackConfig = require('./webpack.config.js')({ production: false, karma: true }); delete webpackConfig.entry; -let frameworks = [ - "mocha", - "chai", - "sinon", - "es6-shim" -]; - -let plugins = [ - "karma-webpack", - "karma-sourcemap-writer", - "karma-sourcemap-loader", - "karma-mocha-reporter", - "karma-mocha", - "karma-chai", - "karma-sinon", - "karma-es6-shim", - "karma-remap-istanbul", - "karma-coverage-istanbul-reporter" -]; - -module.exports = function(config) { +module.exports = (config) => { var configuration = { basePath: "", - frameworks: frameworks, + frameworks: [ + "mocha", + "chai", + "sinon", + "es6-shim" + ], files: [ { pattern: "node_modules/phaser-ce/build/phaser.js", include: true }, { pattern: "./test/**/**/**.test.ts", include: true }, @@ -45,7 +30,18 @@ module.exports = function(config) { webpackMiddleware: { noInfo: true }, - plugins: plugins, + plugins: [ + "karma-webpack", + "karma-sourcemap-writer", + "karma-sourcemap-loader", + "karma-mocha-reporter", + "karma-mocha", + "karma-chai", + "karma-sinon", + "karma-es6-shim", + "karma-remap-istanbul", + "karma-coverage-istanbul-reporter" + ], reporters: ( config.singleRun ? ["dots", "mocha", "coverage-istanbul"] : @@ -65,7 +61,8 @@ module.exports = function(config) { colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: [] + browsers: [], + browserNoActivityTimeout: 50000 }; if (process.env.TRAVIS) { diff --git a/webpack.config.js b/webpack.config.js index f9c9aca..28de858 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,29 +1,42 @@ const webpack = require('webpack'); const path = require('path'); +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); -module.exports = (function(options) { +module.exports = (env) => { - if (!options) options = {isTest: false}; + if (!env) env = { production: false, karma: false }; - var tsconfig = options.isTest ? "tsconfig.test.json" : "tsconfig.json"; + let mode = env.production ? "production" : "development"; + let tsconfig = !env.karma ? "tsconfig.json" : "tsconfig.test.json"; + let output = env.production ? "dist" : "dev"; + let filename = env.production ? "robotlegs-phaser-signalcommandmap.min.js" : "robotlegs-phaser-signalcommandmap.js"; return { + mode: mode, entry: { main: path.join(__dirname, "src/index.ts") }, output: { - path: path.join(__dirname, "dist"), - filename: "bundle.js" + path: path.join(__dirname, output), + filename: filename, + + libraryTarget: "var", + library: "RobotlegsJSPhaserSignalCommandMap" }, - devtool: 'inline-source-map', + devtool: env.production ? undefined : "inline-source-map", module: { rules: [ - { test: /\.ts$/, loader: "ts-loader?configFile=" + tsconfig }, { - test: /^(.(?!\.test))*\.ts$/, + test: /\.ts$/, + loader: "ts-loader?configFile=" + tsconfig + }, + { + test: ((env.production) /* disable this loader for production builds */ + ? /^$/ + : /^(.(?!\.test))*\.ts$/), loader: "istanbul-instrumenter-loader", query: { embedSource: true @@ -33,16 +46,14 @@ module.exports = (function(options) { ] }, - plugins: [ - // new webpack.optimize.UglifyJsPlugin() - new webpack.SourceMapDevToolPlugin({ test: /\.ts$/i }) - ], + plugins: ( + (env.production) + ? [ new UglifyJSPlugin() ] + : [ new webpack.SourceMapDevToolPlugin({ test: /\.ts$/i }) ] + ), resolve: { - extensions: ['.ts', '.js', '.json'], - alias: { - // sinon: 'sinon/pkg/sinon' - } + extensions: ['.ts', '.js', '.json'] } } -}); +}; From ac093af53bd46ddfeebdaea70586f5d38ba0c122 Mon Sep 17 00:00:00 2001 From: Tiago Schenkel Date: Tue, 24 Jul 2018 23:02:41 +0200 Subject: [PATCH 5/8] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34e95f2..d364f17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ - Use `rimraf` instead of `rm -rf` (see #36). +- Update TypeScript Compiler Options (see #38). + - Update dev dependencies to latest version. ### [v0.0.5](https://github.com/RobotlegsJS/RobotlegsJS-Phaser-SignalCommandMap/releases/tag/0.0.5) - 2017-09-26 From e518081fe85db75a03675fe8513147201fa3162e Mon Sep 17 00:00:00 2001 From: Tiago Schenkel Date: Tue, 24 Jul 2018 23:02:53 +0200 Subject: [PATCH 6/8] fix typescript compilation errors --- .../extensions/signalCommandMap/impl/SignalCommandMap.ts | 4 ---- .../extensions/signalCommandMap/impl/SignalCommandTrigger.ts | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap.ts b/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap.ts index e84e7ae..d1faa23 100644 --- a/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap.ts +++ b/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap.ts @@ -10,7 +10,6 @@ import { inject, IInjector, IContext, - ILogger, ICommandTrigger, ICommandMapper, ICommandUnmapper, @@ -35,8 +34,6 @@ export class SignalCommandMap implements ISignalCommandMap { private _triggerMap: CommandTriggerMap; - private _logger: ILogger; - /*============================================================================*/ /* Constructor */ /*============================================================================*/ @@ -46,7 +43,6 @@ export class SignalCommandMap implements ISignalCommandMap { */ constructor(@inject(IContext) context: IContext) { this._injector = context.injector; - this._logger = context.getLogger(this); this._triggerMap = new CommandTriggerMap(this.getKey, this.createTrigger.bind(this)); } diff --git a/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandTrigger.ts b/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandTrigger.ts index 2e59230..982942e 100644 --- a/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandTrigger.ts +++ b/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandTrigger.ts @@ -90,7 +90,7 @@ export class SignalCommandTrigger implements ICommandTrigger { /* Private Functions */ /*============================================================================*/ - private routePayloadToCommands = (...valueObjects): void => { + private routePayloadToCommands = (...valueObjects: any[]): void => { let valueClasses: any[] = valueObjects.map(obj => obj.constructor); let payload: CommandPayload = new CommandPayload(valueObjects, valueClasses); this._executor.executeCommands(this._mappings.getList(), payload); From 52c130faeeb024348b516425ed846974882fa739 Mon Sep 17 00:00:00 2001 From: Tiago Schenkel Date: Tue, 24 Jul 2018 23:05:53 +0200 Subject: [PATCH 7/8] add dev folder into clean-up script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2794c90..3336d0d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "mocha": "mocha test/**/*.test.ts --require ts-node/register", "autoformat": "prettier --config .prettierrc --write {src,test}/**/*.ts", "tslint-check": "tslint-config-prettier-check ./tslint.json", - "clean-up": "rimraf .nyc_output && rimraf coverage && rimraf lib", + "clean-up": "rimraf .nyc_output && rimraf coverage && rimraf lib && rimraf dev", "compile:src": "tsc -d", "compile:test": "tsc -p tsconfig.test.json -d", "prepare": "npm run clean-up && compile:src", From abf932a6530269b23694b042829073af96899a2f Mon Sep 17 00:00:00 2001 From: Tiago Schenkel Date: Tue, 24 Jul 2018 23:12:00 +0200 Subject: [PATCH 8/8] fix prepare script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3336d0d..7584c6d 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "clean-up": "rimraf .nyc_output && rimraf coverage && rimraf lib && rimraf dev", "compile:src": "tsc -d", "compile:test": "tsc -p tsconfig.test.json -d", - "prepare": "npm run clean-up && compile:src", + "prepare": "npm run clean-up && npm run compile:src", "prepublishOnly": "publish-please guard", "publish-please": "npm run autoformat && npm run clean-up && npm run test && publish-please" },