Skip to content

Commit 6067293

Browse files
Merge pull request #38 from RobotlegsJS/tsconfig
Update TypeScript Compiler Options
2 parents 3b14d80 + abf932a commit 6067293

File tree

10 files changed

+71
-55
lines changed

10 files changed

+71
-55
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.idea
22
build
3+
dev
34
lib
45
node_modules
56
typings

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.idea
22
/.vscode
33
/coverage
4+
/dev
45
/dist
56
/docs
67
/lib/test

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
- Use `rimraf` instead of `rm -rf` (see #36).
2424

25+
- Update TypeScript Compiler Options (see #38).
26+
2527
- Update dev dependencies to latest version.
2628

2729
### [v0.0.5](https://github.com/RobotlegsJS/RobotlegsJS-Phaser-SignalCommandMap/releases/tag/0.0.5) - 2017-09-26

karma.conf.js

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,20 @@ process.env.NODE_ENV = 'test';
33

44
const webpack = require("webpack");
55
const path = require("path");
6-
const webpackConfig = require('./webpack.config.js')({ isTest: true });
6+
const webpackConfig = require('./webpack.config.js')({ production: false, karma: true });
77

88
delete webpackConfig.entry;
99

10-
let frameworks = [
11-
"mocha",
12-
"chai",
13-
"sinon",
14-
"es6-shim"
15-
];
16-
17-
let plugins = [
18-
"karma-webpack",
19-
"karma-sourcemap-writer",
20-
"karma-sourcemap-loader",
21-
"karma-mocha-reporter",
22-
"karma-mocha",
23-
"karma-chai",
24-
"karma-sinon",
25-
"karma-es6-shim",
26-
"karma-remap-istanbul",
27-
"karma-coverage-istanbul-reporter"
28-
];
29-
30-
module.exports = function(config) {
10+
module.exports = (config) => {
3111

3212
var configuration = {
3313
basePath: "",
34-
frameworks: frameworks,
14+
frameworks: [
15+
"mocha",
16+
"chai",
17+
"sinon",
18+
"es6-shim"
19+
],
3520
files: [
3621
{ pattern: "node_modules/phaser-ce/build/phaser.js", include: true },
3722
{ pattern: "./test/**/**/**.test.ts", include: true },
@@ -45,7 +30,18 @@ module.exports = function(config) {
4530
webpackMiddleware: {
4631
noInfo: true
4732
},
48-
plugins: plugins,
33+
plugins: [
34+
"karma-webpack",
35+
"karma-sourcemap-writer",
36+
"karma-sourcemap-loader",
37+
"karma-mocha-reporter",
38+
"karma-mocha",
39+
"karma-chai",
40+
"karma-sinon",
41+
"karma-es6-shim",
42+
"karma-remap-istanbul",
43+
"karma-coverage-istanbul-reporter"
44+
],
4945
reporters: (
5046
config.singleRun ?
5147
["dots", "mocha", "coverage-istanbul"] :
@@ -65,7 +61,8 @@ module.exports = function(config) {
6561
colors: true,
6662
logLevel: config.LOG_INFO,
6763
autoWatch: true,
68-
browsers: []
64+
browsers: [],
65+
browserNoActivityTimeout: 50000
6966
};
7067

7168
if (process.env.TRAVIS) {

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
"mocha": "mocha test/**/*.test.ts --require ts-node/register",
1010
"autoformat": "prettier --config .prettierrc --write {src,test}/**/*.ts",
1111
"tslint-check": "tslint-config-prettier-check ./tslint.json",
12-
"clean-up": "rimraf .nyc_output && rimraf coverage && rimraf lib",
13-
"prepare": "npm run clean-up && tsc -d",
12+
"clean-up": "rimraf .nyc_output && rimraf coverage && rimraf lib && rimraf dev",
13+
"compile:src": "tsc -d",
14+
"compile:test": "tsc -p tsconfig.test.json -d",
15+
"prepare": "npm run clean-up && npm run compile:src",
1416
"prepublishOnly": "publish-please guard",
1517
"publish-please": "npm run autoformat && npm run clean-up && npm run test && publish-please"
1618
},

src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
inject,
1111
IInjector,
1212
IContext,
13-
ILogger,
1413
ICommandTrigger,
1514
ICommandMapper,
1615
ICommandUnmapper,
@@ -35,8 +34,6 @@ export class SignalCommandMap implements ISignalCommandMap {
3534

3635
private _triggerMap: CommandTriggerMap;
3736

38-
private _logger: ILogger;
39-
4037
/*============================================================================*/
4138
/* Constructor */
4239
/*============================================================================*/
@@ -46,7 +43,6 @@ export class SignalCommandMap implements ISignalCommandMap {
4643
*/
4744
constructor(@inject(IContext) context: IContext) {
4845
this._injector = context.injector;
49-
this._logger = context.getLogger(this);
5046
this._triggerMap = new CommandTriggerMap(this.getKey, this.createTrigger.bind(this));
5147
}
5248

src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandTrigger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class SignalCommandTrigger implements ICommandTrigger {
9090
/* Private Functions */
9191
/*============================================================================*/
9292

93-
private routePayloadToCommands = (...valueObjects): void => {
93+
private routePayloadToCommands = (...valueObjects: any[]): void => {
9494
let valueClasses: any[] = valueObjects.map(obj => obj.constructor);
9595
let payload: CommandPayload = new CommandPayload(valueObjects, valueClasses);
9696
this._executor.executeCommands(this._mappings.getList(), payload);

tsconfig.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
"module": "commonjs",
77
"moduleResolution": "node",
88
"declaration": true,
9-
"noImplicitAny": false,
10-
"sourceMap": true,
119
"experimentalDecorators": true,
12-
"emitDecoratorMetadata": true
10+
"emitDecoratorMetadata": true,
11+
"noImplicitAny": true,
12+
"noUnusedParameters": false,
13+
"noUnusedLocals": true,
14+
"removeComments": true,
15+
"sourceMap": false
1316
},
1417
"include": [
1518
"./src/**/*.ts"

tsconfig.test.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
"module": "commonjs",
77
"moduleResolution": "node",
88
"declaration": true,
9-
"noImplicitAny": false,
10-
"sourceMap": true,
119
"experimentalDecorators": true,
12-
"emitDecoratorMetadata": true
10+
"emitDecoratorMetadata": true,
11+
"noImplicitAny": true,
12+
"noUnusedParameters": false,
13+
"noUnusedLocals": true,
14+
"removeComments": true,
15+
"sourceMap": true
1316
},
1417
"include": [
1518
"./src/**/*.ts",

webpack.config.js

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
11
const webpack = require('webpack');
22
const path = require('path');
3+
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
34

4-
module.exports = (function(options) {
5+
module.exports = (env) => {
56

6-
if (!options) options = {isTest: false};
7+
if (!env) env = { production: false, karma: false };
78

8-
var tsconfig = options.isTest ? "tsconfig.test.json" : "tsconfig.json";
9+
let mode = env.production ? "production" : "development";
10+
let tsconfig = !env.karma ? "tsconfig.json" : "tsconfig.test.json";
11+
let output = env.production ? "dist" : "dev";
12+
let filename = env.production ? "robotlegs-phaser-signalcommandmap.min.js" : "robotlegs-phaser-signalcommandmap.js";
913

1014
return {
15+
mode: mode,
1116
entry: {
1217
main: path.join(__dirname, "src/index.ts")
1318
},
1419

1520
output: {
16-
path: path.join(__dirname, "dist"),
17-
filename: "bundle.js"
21+
path: path.join(__dirname, output),
22+
filename: filename,
23+
24+
libraryTarget: "var",
25+
library: "RobotlegsJSPhaserSignalCommandMap"
1826
},
1927

20-
devtool: 'inline-source-map',
28+
devtool: env.production ? undefined : "inline-source-map",
2129

2230
module: {
2331
rules: [
24-
{ test: /\.ts$/, loader: "ts-loader?configFile=" + tsconfig },
2532
{
26-
test: /^(.(?!\.test))*\.ts$/,
33+
test: /\.ts$/,
34+
loader: "ts-loader?configFile=" + tsconfig
35+
},
36+
{
37+
test: ((env.production) /* disable this loader for production builds */
38+
? /^$/
39+
: /^(.(?!\.test))*\.ts$/),
2740
loader: "istanbul-instrumenter-loader",
2841
query: {
2942
embedSource: true
@@ -33,16 +46,14 @@ module.exports = (function(options) {
3346
]
3447
},
3548

36-
plugins: [
37-
// new webpack.optimize.UglifyJsPlugin()
38-
new webpack.SourceMapDevToolPlugin({ test: /\.ts$/i })
39-
],
49+
plugins: (
50+
(env.production)
51+
? [ new UglifyJSPlugin() ]
52+
: [ new webpack.SourceMapDevToolPlugin({ test: /\.ts$/i }) ]
53+
),
4054

4155
resolve: {
42-
extensions: ['.ts', '.js', '.json'],
43-
alias: {
44-
// sinon: 'sinon/pkg/sinon'
45-
}
56+
extensions: ['.ts', '.js', '.json']
4657
}
4758
}
48-
});
59+
};

0 commit comments

Comments
 (0)