Skip to content

Commit 2203bba

Browse files
Merge pull request #42 from RobotlegsJS/tsconfig
Update TypeScript Compiler Options
2 parents 981ed5d + 9300823 commit 2203bba

File tree

10 files changed

+220
-60
lines changed

10 files changed

+220
-60
lines changed

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
.idea
2-
build
3-
dev
2+
.nyc_output
3+
coverage
4+
dist
5+
dist-test
46
lib
7+
lib-test
58
node_modules
6-
typings
7-
coverage
8-
inversify.d.ts
99
*.as
1010
*.iml
1111
src/**/*.js
1212
src/**/*.js.map
1313
test/**/*.js
1414
test/**/*.js.map
1515
npm-debug.log
16+
yarn-error.log

.npmignore

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/.idea
2+
/.nyc_output
23
/.vscode
34
/coverage
4-
/dev
55
/dist
6+
/dist-test
67
/docs
7-
/lib/test
8+
/example
9+
/lib-test
810
/not-ported-extensions
911
/src
1012
/test
@@ -14,23 +16,18 @@ CODE_OF_CONDUCT.md
1416
CONTRIBUTING.md
1517
ISSUE_TEMPLATE.md
1618
PULL_REQUEST_TEMPLATE.md
17-
bower.json
1819
karma.conf.js
1920
tsconfig.json
2021
tsconfig.test.json
21-
tsfmt.json
2222
tslint.json
2323
tslint.test.json
24-
typings.json
2524
webpack.config.js
25+
webpack.example.config.js
2626
yarn.lock
27-
.codeclimate.yml
2827
.editorconfig
29-
.eslintignore
30-
.eslintrc
3128
.gitignore
3229
.istanbul.yml
3330
.npmignore
3431
.prettierrc
3532
.publishrc
36-
.travis.yml
33+
.travis.yml

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

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

25-
- Update TypeScript Compiler Options (see #38).
25+
- Update TypeScript Compiler Options (see #38, #42).
26+
27+
- Use [tslib](https://github.com/Microsoft/tslib) library to avoid duplicated declarations (see #42).
2628

2729
- Enforce TSLint rules (see #39).
2830

karma.conf.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
process.env.TEST = true;
2-
process.env.NODE_ENV = 'test';
2+
process.env.NODE_ENV = "test";
33

4-
const webpack = require("webpack");
5-
const path = require("path");
6-
const webpackConfig = require('./webpack.config.js')({ production: false, karma: true });
4+
const webpackConfig = require("./webpack.config.js")({ production: false, karma: true });
75

86
delete webpackConfig.entry;
97

10-
module.exports = (config) => {
8+
module.exports = config => {
119

1210
var configuration = {
1311
basePath: "",
@@ -18,6 +16,8 @@ module.exports = (config) => {
1816
"es6-shim"
1917
],
2018
files: [
19+
{ pattern: "node_modules/reflect-metadata/Reflect.js", include: true },
20+
{ pattern: "node_modules/bluebird/js/browser/bluebird.js", include: true },
2121
{ pattern: "node_modules/phaser-ce/build/phaser.js", include: true },
2222
{ pattern: "./test/**/**/**.test.ts", include: true },
2323
{ pattern: '**/*.map', served: true, included: false, watched: true }
@@ -34,12 +34,12 @@ module.exports = (config) => {
3434
"karma-webpack",
3535
"karma-sourcemap-writer",
3636
"karma-sourcemap-loader",
37+
"karma-remap-istanbul",
3738
"karma-mocha-reporter",
3839
"karma-mocha",
3940
"karma-chai",
4041
"karma-sinon",
4142
"karma-es6-shim",
42-
"karma-remap-istanbul",
4343
"karma-coverage-istanbul-reporter"
4444
],
4545
reporters: (
@@ -66,10 +66,10 @@ module.exports = (config) => {
6666
};
6767

6868
if (process.env.TRAVIS) {
69-
configuration.browsers = ['PhantomJS'];
69+
configuration.browsers.push("PhantomJS");
7070
configuration.plugins.push("karma-phantomjs-launcher");
7171
} else {
72-
configuration.browsers = ['PhantomJS'];
72+
configuration.browsers.push("PhantomJS");
7373
configuration.plugins.push("karma-phantomjs-launcher");
7474
}
7575

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
"tslint:src": "tslint --project tsconfig.json",
1414
"tslint:test": "tslint --config tslint.test.json --project tsconfig.test.json",
1515
"tslint": "npm run tslint-check:src && npm run tslint-check:test && npm run tslint:src && npm run tslint:test",
16-
"clean-up": "rimraf .nyc_output && rimraf coverage && rimraf lib && rimraf dev",
17-
"compile:src": "tsc -d",
18-
"compile:test": "tsc -p tsconfig.test.json -d",
16+
"clean-up": "rimraf .nyc_output && rimraf coverage && rimraf lib && rimraf lib-test && rimraf dist && rimraf dist-test",
17+
"compile:src": "tsc -d --importHelpers",
18+
"compile:test": "tsc -p tsconfig.test.json -d --importHelpers",
19+
"dev": "webpack",
20+
"build": "webpack --env.production",
1921
"prepare": "npm run clean-up && npm run compile:src",
2022
"prepublishOnly": "publish-please guard",
2123
"publish-please": "npm run tslint && npm run autoformat && npm run clean-up && npm run test && publish-please"
@@ -44,7 +46,8 @@
4446
"homepage": "https://github.com/RobotlegsJS/RobotlegsJS-Phaser-SignalCommandMap#readme",
4547
"dependencies": {
4648
"@robotlegsjs/core": "^0.1.3",
47-
"phaser-ce": "^2.11.0"
49+
"phaser-ce": "^2.11.0",
50+
"tslib": "^1.9.3"
4851
},
4952
"devDependencies": {
5053
"@types/bluebird": "^3.5.23",
@@ -88,6 +91,7 @@
8891
"tslint-config-prettier": "^1.14.0",
8992
"typescript": "^2.9.2",
9093
"webpack": "^4.16.3",
94+
"webpack-cli": "^3.1.0",
9195
"webpack-dev-server": "^3.1.5"
9296
},
9397
"peerDependencies": {

test/entry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// in accordance with the terms of the license agreement accompanying it.
66
// ------------------------------------------------------------------------------
77

8+
/// <reference types="mocha" />
9+
810
import "reflect-metadata";
911
import "bluebird/js/browser/bluebird";
1012
import "es6-symbol/implement";

tsconfig.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22
"compilerOptions": {
33
"outDir": "lib",
44
"target": "es5",
5-
"lib": ["es6", "dom"],
5+
"lib": ["es7", "dom"],
6+
"types": ["reflect-metadata"],
7+
"sourceMap": true,
8+
"inlineSources": true,
69
"module": "commonjs",
710
"moduleResolution": "node",
8-
"declaration": true,
911
"experimentalDecorators": true,
1012
"emitDecoratorMetadata": true,
13+
"removeComments": false,
14+
"strict": false,
1115
"noImplicitAny": true,
12-
"noUnusedParameters": false,
16+
"strictNullChecks": false,
17+
"noImplicitThis": false,
18+
"alwaysStrict": true,
1319
"noUnusedLocals": true,
14-
"removeComments": true,
15-
"sourceMap": false
20+
"noUnusedParameters": false,
21+
"noImplicitReturns": true,
22+
"noFallthroughCasesInSwitch": true
1623
},
1724
"include": [
1825
"./src/**/*.ts"

tsconfig.test.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
{
2+
"extends": "./tsconfig.json",
23
"compilerOptions": {
3-
"outDir": "lib",
4-
"target": "es5",
5-
"lib": ["es6", "dom"],
6-
"module": "commonjs",
7-
"moduleResolution": "node",
8-
"declaration": true,
9-
"experimentalDecorators": true,
10-
"emitDecoratorMetadata": true,
11-
"noImplicitAny": true,
12-
"noUnusedParameters": false,
13-
"noUnusedLocals": true,
14-
"removeComments": true,
15-
"sourceMap": true
4+
"outDir": "lib-test"
165
},
176
"include": [
187
"./src/**/*.ts",
198
"./test/**/*.ts"
20-
],
21-
"files": [
22-
"./node_modules/phaser-ce/typescript/phaser.d.ts"
239
]
2410
}

webpack.config.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
const webpack = require('webpack');
2-
const path = require('path');
3-
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
1+
const webpack = require("webpack");
2+
const path = require("path");
3+
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
44

5-
module.exports = (env) => {
5+
module.exports = env => {
66

77
if (!env) env = { production: false, karma: false };
88

99
let mode = env.production ? "production" : "development";
1010
let tsconfig = !env.karma ? "tsconfig.json" : "tsconfig.test.json";
11-
let output = env.production ? "dist" : "dev";
11+
let output = env.production ? "dist" : "dist-test";
1212
let filename = env.production ? "robotlegs-phaser-signalcommandmap.min.js" : "robotlegs-phaser-signalcommandmap.js";
1313

1414
return {
1515
mode: mode,
16+
1617
entry: {
1718
main: path.join(__dirname, "src/index.ts")
1819
},
@@ -48,12 +49,32 @@ module.exports = (env) => {
4849

4950
plugins: (
5051
(env.production)
51-
? [ new UglifyJSPlugin() ]
52+
? []
5253
: [ new webpack.SourceMapDevToolPlugin({ test: /\.ts$/i }) ]
5354
),
5455

56+
optimization:
57+
(env.production)
58+
? {
59+
concatenateModules: true,
60+
minimize: true,
61+
minimizer: [
62+
new UglifyJsPlugin({
63+
cache: true,
64+
parallel: 4,
65+
uglifyOptions: {
66+
output: {
67+
comments: false
68+
}
69+
}
70+
})
71+
]
72+
}
73+
: {}
74+
,
75+
5576
resolve: {
56-
extensions: ['.ts', '.js', '.json']
77+
extensions: [".ts", ".js", ".json"]
5778
}
5879
}
5980
};

0 commit comments

Comments
 (0)