Skip to content

Commit a857843

Browse files
Merge pull request #106 from RobotlegsJS/migrate-to-terser-webpack-plugin
Migrate to terser-webpack-plugin
2 parents 4db68d3 + 9bd0ace commit a857843

File tree

5 files changed

+1208
-828
lines changed

5 files changed

+1208
-828
lines changed

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
"trailingComma": "none",
88
"bracketSpacing": true,
99
"overrides": [
10+
{
11+
"files": "*.js",
12+
"options": {
13+
"tabWidth": 2
14+
}
15+
},
1016
{
1117
"files": "*.json",
1218
"options": {

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ Types of changes:
4141
- in case of vulnerabilities.
4242
-->
4343

44+
#### Security
45+
46+
- Migrate to [terser-webpack-plugin](https://github.com/webpack-contrib/terser-webpack-plugin) to solve security vulnerability (see #106).
47+
4448
## RobotlegsJS-SignalCommandMap 1.0.0
4549

4650
### [v1.0.2](https://github.com/RobotlegsJS/RobotlegsJS-SignalCommandMap/releases/tag/1.0.2) - 2019-10-24

package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,49 +77,49 @@
7777
"@robotlegsjs/signals": "^1.0.3"
7878
},
7979
"devDependencies": {
80-
"@istanbuljs/nyc-config-typescript": "^0.1.3",
81-
"@types/bluebird": "^3.5.28",
82-
"@types/chai": "^4.2.4",
83-
"@types/mocha": "^5.2.7",
84-
"@types/sinon": "^7.5.0",
85-
"@types/webpack-env": "^1.14.1",
86-
"bluebird": "^3.7.1",
80+
"@istanbuljs/nyc-config-typescript": "^1.0.1",
81+
"@types/bluebird": "^3.5.29",
82+
"@types/chai": "^4.2.8",
83+
"@types/mocha": "^7.0.1",
84+
"@types/sinon": "^7.5.1",
85+
"@types/webpack-env": "^1.15.1",
86+
"bluebird": "^3.7.2",
8787
"browserify-versionify": "^1.0.6",
8888
"chai": "^4.2.0",
8989
"es6-map": "^0.1.5",
90-
"es6-symbol": "^3.1.2",
90+
"es6-symbol": "^3.1.3",
9191
"glslify": "^7.0.0",
9292
"imports-loader": "^0.8.0",
9393
"istanbul-instrumenter-loader": "^3.0.1",
9494
"karma": "^4.4.1",
9595
"karma-chrome-launcher": "^3.1.0",
96-
"karma-coverage-istanbul-reporter": "^2.1.0",
96+
"karma-coverage-istanbul-reporter": "^2.1.1",
9797
"karma-es6-shim": "^1.0.0",
9898
"karma-mocha": "^1.3.0",
9999
"karma-mocha-reporter": "^2.2.5",
100100
"karma-sinon-chai": "^2.0.2",
101101
"karma-sourcemap-loader": "^0.3.7",
102102
"karma-sourcemap-writer": "^0.1.2",
103103
"karma-webpack": "^4.0.2",
104-
"mocha": "^6.2.2",
105-
"nyc": "^14.1.1",
106-
"prettier": "^1.18.2",
104+
"mocha": "^7.0.1",
105+
"nyc": "^15.0.0",
106+
"prettier": "^1.19.1",
107107
"publish-please": "^5.5.1",
108-
"puppeteer": "^2.0.0",
108+
"puppeteer": "^2.1.1",
109109
"reflect-metadata": "^0.1.13",
110-
"rimraf": "^3.0.0",
111-
"sinon": "^7.5.0",
112-
"sinon-chai": "^3.3.0",
113-
"source-map-support": "^0.5.13",
110+
"rimraf": "^3.0.2",
111+
"sinon": "^8.1.1",
112+
"sinon-chai": "^3.4.0",
113+
"source-map-support": "^0.5.16",
114+
"terser-webpack-plugin": "^2.3.4",
114115
"ts-loader": "^6.2.1",
115-
"ts-node": "^8.4.1",
116-
"tslint": "^5.20.0",
116+
"ts-node": "^8.6.2",
117+
"tslint": "^6.0.0",
117118
"tslint-config-prettier": "^1.18.0",
118-
"typescript": "^3.6.4",
119-
"uglifyjs-webpack-plugin": "^2.2.0",
120-
"webpack": "^4.41.2",
121-
"webpack-cli": "^3.3.9",
122-
"webpack-dev-server": "^3.9.0"
119+
"typescript": "^3.7.5",
120+
"webpack": "^4.41.5",
121+
"webpack-cli": "^3.3.10",
122+
"webpack-dev-server": "^3.10.3"
123123
},
124124
"peerDependencies": {}
125125
}

webpack.config.js

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
const webpack = require("webpack");
22
const path = require("path");
3-
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
3+
const TerserPlugin = require("terser-webpack-plugin");
44

55
module.exports = env => {
6-
76
if (!env) env = { production: false, karma: false };
87

98
let mode = env.production ? "production" : "development";
109
let tsconfig = !env.karma ? "tsconfig.json" : "tsconfig.test.json";
1110
let output = env.production ? "dist" : "dist-test";
12-
let filename = env.karma ? "[name].[hash].js" : (env.production ? "robotlegs-signalcommandmap.min.js" : "robotlegs-signalcommandmap.js");
11+
let filename = env.karma ? "[name].[hash].js" : env.production ? "robotlegs-signalcommandmap.min.js" : "robotlegs-signalcommandmap.js";
1312

1413
return {
1514
mode: mode,
@@ -35,9 +34,7 @@ module.exports = env => {
3534
loader: "ts-loader?configFile=" + tsconfig
3635
},
3736
{
38-
test: ((env.production) /* disable this loader for production builds */
39-
? /^$/
40-
: /^.*(src).*\.ts$/),
37+
test: env.production /* disable this loader for production builds */ ? /^$/ : /^.*(src).*\.ts$/,
4138
loader: "istanbul-instrumenter-loader",
4239
query: {
4340
embedSource: true
@@ -47,34 +44,27 @@ module.exports = env => {
4744
]
4845
},
4946

50-
plugins: (
51-
(env.production)
52-
? []
53-
: [ new webpack.SourceMapDevToolPlugin({ test: /\.ts$/i }) ]
54-
),
47+
plugins: env.production ? [] : [new webpack.SourceMapDevToolPlugin({ test: /\.ts$/i })],
5548

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-
}
49+
optimization: env.production
50+
? {
51+
concatenateModules: true,
52+
minimize: true,
53+
minimizer: [
54+
new TerserPlugin({
55+
cache: true,
56+
parallel: 4,
57+
terserOptions: {
58+
output: {
59+
comments: false
6960
}
70-
})
71-
]
72-
}
73-
: {}
74-
,
75-
61+
}
62+
})
63+
]
64+
}
65+
: {},
7666
resolve: {
7767
extensions: [".ts", ".js", ".json"]
7868
}
79-
}
69+
};
8070
};

0 commit comments

Comments
 (0)