Skip to content

Commit

Permalink
Merge pull request #38 from RobotlegsJS/tsconfig
Browse files Browse the repository at this point in the history
Update TypeScript Compiler Options
  • Loading branch information
tiagoschenkel authored Jul 24, 2018
2 parents 3b14d80 + abf932a commit 6067293
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
build
dev
lib
node_modules
typings
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.idea
/.vscode
/coverage
/dev
/dist
/docs
/lib/test
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 22 additions & 25 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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"] :
Expand All @@ -65,7 +61,8 @@ module.exports = function(config) {
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: []
browsers: [],
browserNoActivityTimeout: 50000
};

if (process.env.TRAVIS) {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"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",
"prepare": "npm run clean-up && tsc -d",
"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 && npm run compile:src",
"prepublishOnly": "publish-please guard",
"publish-please": "npm run autoformat && npm run clean-up && npm run test && publish-please"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
inject,
IInjector,
IContext,
ILogger,
ICommandTrigger,
ICommandMapper,
ICommandUnmapper,
Expand All @@ -35,8 +34,6 @@ export class SignalCommandMap implements ISignalCommandMap {

private _triggerMap: CommandTriggerMap;

private _logger: ILogger;

/*============================================================================*/
/* Constructor */
/*============================================================================*/
Expand All @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
45 changes: 28 additions & 17 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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']
}
}
});
};

0 comments on commit 6067293

Please sign in to comment.