Switch from uglifyjs-webpack-plugin to terser-webpack-plugin

Some history:
* `uglifyjs-webpack-plugin` < v1.0 used the minifier `uglify-js`
* however `uglify-js` does not support ES6, which resulted in a fork
  called `uglify-es` that was developed in the `uglify-js` repository,
  but under the `harmony` branch
* `uglifyjs-webpack-plugin` v1.x switched to `uglify-es` for ES6 support
* however `uglify-es` stopped being maintained:
  https://github.com/mishoo/UglifyJS2/issues/3156#issuecomment-392943058
* which led to a fork called `terser` that has incorporated all of
  the unmerged PRs and will be where all new development occurs:
  https://github.com/fabiosantoscode/terser
* `terser-webpack-plugin` was created, which is the `terser` equivalent
  of `uglifyjs-webpack-plugin`:
  https://github.com/webpack-contrib/terser-webpack-plugin
* `uglifyjs-webpack-plugin` v2.x will be switching back to `uglify-js`,
  so any project that needs to support ES6 now needs to switch to
  `terser-webpack-plugin`.

Fixes #7923.
This commit is contained in:
Ed Morley 2018-09-10 00:16:35 +01:00
parent 97ed999aad
commit 79910c6ba5
13 changed files with 221 additions and 164 deletions

View File

@ -17,7 +17,7 @@ webpack(
moduleIds: "named"
},
plugins: [
new webpack.IgnorePlugin(/^(fsevents|uglify-js)$/),
new webpack.IgnorePlugin(/^(fsevents|terser)$/),
new webpack.NormalModuleReplacementPlugin(
/^.\/loadLoader$/,
path.resolve(__dirname, "./createBenchmark/loadLoader")

View File

@ -101,7 +101,7 @@ Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin
+ 1 hidden module
```
## Minimized (uglify-js, no zip)
## Minimized (terser, no zip)
```
Hash: edbe0e91ba86d814d855

View File

@ -292,10 +292,10 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("optimization.minimizer", "make", options => [
{
apply: compiler => {
// Lazy load the uglifyjs plugin
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
// Lazy load the Terser plugin
const TerserPlugin = require("terser-webpack-plugin");
const SourceMapDevToolPlugin = require("./SourceMapDevToolPlugin");
new UglifyJsPlugin({
new TerserPlugin({
cache: true,
parallel: true,
sourceMap:

View File

@ -27,7 +27,7 @@
"node-libs-browser": "^2.0.0",
"schema-utils": "^0.4.4",
"tapable": "^1.1.0",
"uglifyjs-webpack-plugin": "^1.2.4",
"terser-webpack-plugin": "^1.1.0",
"watchpack": "^1.5.0",
"webpack-sources": "^1.2.0"
},

View File

@ -5,14 +5,14 @@ const path = require("path");
const fs = require("fs");
const vm = require("vm");
const mkdirp = require("mkdirp");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const checkArrayExpectation = require("./checkArrayExpectation");
const createLazyTestEnv = require("./helpers/createLazyTestEnv");
const Stats = require("../lib/Stats");
const webpack = require("../lib/webpack");
const uglifyJsForTesting = new UglifyJsPlugin({
const terserForTesting = new TerserPlugin({
cache: false,
parallel: false,
sourceMap: true
@ -30,12 +30,12 @@ const DEFAULT_OPTIMIZATIONS = {
concatenateModules: false,
moduleIds: "size",
chunkIds: "size",
minimizer: [uglifyJsForTesting]
minimizer: [terserForTesting]
};
const NO_EMIT_ON_ERRORS_OPTIMIZATIONS = {
noEmitOnErrors: false,
minimizer: [uglifyJsForTesting]
minimizer: [terserForTesting]
};
const casesPath = path.join(__dirname, "cases");

View File

@ -776,35 +776,35 @@ Child undefined:
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
WARNING in UglifyJs Plugin: Dropping side-effect-free statement [./index.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] in bundle.js
Child UglifyJs:
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0]
Child Terser:
Hash: 70b5eb88941464457a7d
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
Child /UglifyJs/:
Child /Terser/:
Hash: 70b5eb88941464457a7d
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
@ -818,14 +818,14 @@ Child warnings => true:
Asset Size Chunks Chunk Names
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
Child [UglifyJs]:
Child [Terser]:
Hash: 70b5eb88941464457a7d
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
Child [/UglifyJs/]:
Child [/Terser/]:
Hash: 70b5eb88941464457a7d
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
@ -847,27 +847,27 @@ Child should not filter:
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
WARNING in UglifyJs Plugin: Dropping side-effect-free statement [./index.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0]
Child /should not filter/:
Hash: 70b5eb88941464457a7d
Time: Xms
@ -876,27 +876,27 @@ Child /should not filter/:
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
WARNING in UglifyJs Plugin: Dropping side-effect-free statement [./index.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0]
Child warnings => false:
Hash: 70b5eb88941464457a7d
Time: Xms
@ -905,27 +905,27 @@ Child warnings => false:
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
WARNING in UglifyJs Plugin: Dropping side-effect-free statement [./index.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0]
Child [should not filter]:
Hash: 70b5eb88941464457a7d
Time: Xms
@ -934,27 +934,27 @@ Child [should not filter]:
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
WARNING in UglifyJs Plugin: Dropping side-effect-free statement [./index.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0]
Child [/should not filter/]:
Hash: 70b5eb88941464457a7d
Time: Xms
@ -963,27 +963,27 @@ Child [/should not filter/]:
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
WARNING in UglifyJs Plugin: Dropping side-effect-free statement [./index.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0]
Child [warnings => false]:
Hash: 70b5eb88941464457a7d
Time: Xms
@ -992,27 +992,27 @@ Child [warnings => false]:
bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
WARNING in UglifyJs Plugin: Dropping side-effect-free statement [./index.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction1 [./index.js:8,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction2 [./index.js:9,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction3 [./index.js:10,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction4 [./index.js:11,0]
WARNING in UglifyJs Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction1 [./a.js:3,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction2 [./a.js:4,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction3 [./a.js:5,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] in bundle.js
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0]
WARNING in UglifyJs Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] in bundle.js"
WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0]"
`;
exports[`StatsTestCases should print correct stats for graph-correctness-entries 1`] = `
@ -3118,15 +3118,5 @@ bundle.js 2.84 KiB 0 [emitted] main
Entrypoint main = bundle.js
[0] ./index.js 299 bytes {0} [built]
[1] ./a.js 249 bytes {0} [built]
[2] (webpack)/buildin/module.js 497 bytes {0} [built]
WARNING in UglifyJs Plugin: Dropping unused function someUnRemoteUsedFunction1 [./a.js:3,0] in bundle.js
WARNING in UglifyJs Plugin: Dropping unused function someUnRemoteUsedFunction2 [./a.js:4,0] in bundle.js
WARNING in UglifyJs Plugin: Dropping unused function someUnRemoteUsedFunction3 [./a.js:5,0] in bundle.js
WARNING in UglifyJs Plugin: Dropping unused function someUnRemoteUsedFunction4 [./a.js:6,0] in bundle.js
WARNING in UglifyJs Plugin: Dropping unused function someUnRemoteUsedFunction5 [./a.js:7,0] in bundle.js"
[2] (webpack)/buildin/module.js 497 bytes {0} [built]"
`;

View File

@ -1,7 +1,7 @@
const supportsOptionalCatchBinding = require("../../../helpers/supportsOptionalCatchBinding");
module.exports = function(config) {
// XXX: Disable this test if UglifyJS is used because it does not support ES 2019
// XXX: Disable this test if Terser is used because it does not support ES 2019
if (config.mode === "production") {
return false;
}

View File

@ -17,7 +17,7 @@ module.exports = function checkArrayExpectation(
}
let array = object[`${kind}s`];
if (kind === "warning")
array = array.filter(item => !/from UglifyJs/.test(item));
array = array.filter(item => !/from Terser/.test(item));
if (fs.existsSync(path.join(testDirectory, `${filename}.js`))) {
const expectedFilename = path.join(testDirectory, `${filename}.js`);
const expected = require(expectedFilename);

View File

@ -1,5 +1,5 @@
var webpack = require("../../../../");
var UglifyJsPlugin = require("uglifyjs-webpack-plugin");
var TerserPlugin = require("terser-webpack-plugin");
module.exports = {
node: {
__dirname: false,
@ -14,7 +14,7 @@ module.exports = {
},
optimization: {
minimizer: [
new UglifyJsPlugin({
new TerserPlugin({
sourceMap: true
})
]

View File

@ -1,4 +1,4 @@
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
node: {
__dirname: false,
@ -17,21 +17,21 @@ module.exports = {
optimization: {
minimize: true,
minimizer: [
new UglifyJsPlugin({
new TerserPlugin({
cache: false,
parallel: false,
exclude: ["vendors.js", "extract.js"]
}),
new UglifyJsPlugin({
new TerserPlugin({
cache: false,
parallel: false,
extractComments: true,
include: ["extract.js"]
}),
new UglifyJsPlugin({
new TerserPlugin({
cache: false,
parallel: false,
uglifyOptions: {
terserOptions: {
compress: {
passes: 2
}

View File

@ -1,4 +1,4 @@
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const baseConfig = {
mode: "production",
entry: "./index",
@ -10,9 +10,9 @@ const baseConfig = {
chunkIds: "natural",
minimize: true,
minimizer: [
new UglifyJsPlugin({
new TerserPlugin({
sourceMap: true,
uglifyOptions: {
terserOptions: {
compress: {
warnings: true
},
@ -36,11 +36,11 @@ const baseConfig = {
module.exports = [
undefined,
"UglifyJs",
/UglifyJs/,
"Terser",
/Terser/,
warnings => true,
["UglifyJs"],
[/UglifyJs/],
["Terser"],
[/Terser/],
[warnings => true],
"should not filter",
/should not filter/,

View File

@ -1,4 +1,4 @@
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
mode: "production",
entry: "./index",
@ -10,9 +10,9 @@ module.exports = {
chunkIds: "natural",
minimize: true,
minimizer: [
new UglifyJsPlugin({
new TerserPlugin({
sourceMap: true,
uglifyOptions: {
terserOptions: {
compress: {
warnings: true
},

153
yarn.lock
View File

@ -245,6 +245,10 @@ acorn@^5.0.3, acorn@^5.6.0, acorn@^5.6.2:
version "5.7.2"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.2.tgz#91fa871883485d06708800318404e72bfb26dcc5"
ajv-errors@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.0.tgz#ecf021fa108fd17dfb5e6b383f2dd233e31ffc59"
ajv-keywords@^3.0.0, ajv-keywords@^3.1.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.2.0.tgz#e86b819c602cf8821ad637413698f1dec021847a"
@ -828,21 +832,22 @@ bundle-loader@~0.5.0:
dependencies:
loader-utils "^1.1.0"
cacache@^10.0.4:
version "10.0.4"
resolved "https://registry.yarnpkg.com/cacache/-/cacache-10.0.4.tgz#6452367999eff9d4188aefd9a14e9d7c6a263460"
cacache@^11.0.2:
version "11.2.0"
resolved "https://registry.yarnpkg.com/cacache/-/cacache-11.2.0.tgz#617bdc0b02844af56310e411c0878941d5739965"
dependencies:
bluebird "^3.5.1"
chownr "^1.0.1"
figgy-pudding "^3.1.0"
glob "^7.1.2"
graceful-fs "^4.1.11"
lru-cache "^4.1.1"
mississippi "^2.0.0"
lru-cache "^4.1.3"
mississippi "^3.0.0"
mkdirp "^0.5.1"
move-concurrently "^1.0.1"
promise-inflight "^1.0.1"
rimraf "^2.6.2"
ssri "^5.2.4"
ssri "^6.0.0"
unique-filename "^1.1.0"
y18n "^4.0.0"
@ -1163,9 +1168,9 @@ commander@^2.14.1, commander@^2.9.0, commander@^2.x:
version "2.15.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"
commander@~2.13.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"
commander@~2.17.1:
version "2.17.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
commondir@^1.0.1:
version "1.0.1"
@ -2051,6 +2056,10 @@ fbjs@^0.8.16, fbjs@^0.8.9:
setimmediate "^1.0.5"
ua-parser-js "^0.7.9"
figgy-pudding@^3.1.0, figgy-pudding@^3.5.1:
version "3.5.1"
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790"
figures@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e"
@ -2108,13 +2117,13 @@ fill-range@^4.0.0:
repeat-string "^1.6.1"
to-regex-range "^2.1.0"
find-cache-dir@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f"
find-cache-dir@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.0.0.tgz#4c1faed59f45184530fb9d7fa123a4d04a98472d"
dependencies:
commondir "^1.0.1"
make-dir "^1.0.0"
pkg-dir "^2.0.0"
pkg-dir "^3.0.0"
find-parent-dir@^0.3.0:
version "0.3.0"
@ -2133,6 +2142,12 @@ find-up@^2.1.0:
dependencies:
locate-path "^2.0.0"
find-up@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
dependencies:
locate-path "^3.0.0"
flat-cache@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481"
@ -3745,6 +3760,13 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"
locate-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
dependencies:
p-locate "^3.0.0"
path-exists "^3.0.0"
lodash.camelcase@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
@ -3808,7 +3830,7 @@ loose-envify@^1.1.0, loose-envify@^1.3.1:
dependencies:
js-tokens "^3.0.0"
lru-cache@^4.0.1, lru-cache@^4.1.1:
lru-cache@^4.0.1, lru-cache@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c"
dependencies:
@ -3993,9 +4015,9 @@ minizlib@^1.1.0:
dependencies:
minipass "^2.2.1"
mississippi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-2.0.0.tgz#3442a508fafc28500486feea99409676e4ee5a6f"
mississippi@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022"
dependencies:
concat-stream "^1.5.0"
duplexify "^3.4.2"
@ -4003,7 +4025,7 @@ mississippi@^2.0.0:
flush-write-stream "^1.0.0"
from2 "^2.1.0"
parallel-transform "^1.1.0"
pump "^2.0.1"
pump "^3.0.0"
pumpify "^1.3.3"
stream-each "^1.1.0"
through2 "^2.0.0"
@ -4377,12 +4399,24 @@ p-limit@^1.1.0:
dependencies:
p-try "^1.0.0"
p-limit@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.0.0.tgz#e624ed54ee8c460a778b3c9f3670496ff8a57aec"
dependencies:
p-try "^2.0.0"
p-locate@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43"
dependencies:
p-limit "^1.1.0"
p-locate@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4"
dependencies:
p-limit "^2.0.0"
p-map@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/p-map/-/p-map-1.2.0.tgz#e4e94f311eabbc8633a1e79908165fca26241b6b"
@ -4391,6 +4425,10 @@ p-try@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
p-try@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1"
pako@~1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"
@ -4533,6 +4571,12 @@ pkg-dir@^2.0.0:
dependencies:
find-up "^2.1.0"
pkg-dir@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3"
dependencies:
find-up "^3.0.0"
platform@^1.3.3:
version "1.3.5"
resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.5.tgz#fb6958c696e07e2918d2eeda0f0bc9448d733444"
@ -4988,13 +5032,20 @@ pug@^2.0.3:
pug-runtime "^2.0.4"
pug-strip-comments "^1.0.3"
pump@^2.0.0, pump@^2.0.1:
pump@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909"
dependencies:
end-of-stream "^1.1.0"
once "^1.3.1"
pump@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
dependencies:
end-of-stream "^1.1.0"
once "^1.3.1"
pumpify@^1.3.3:
version "1.5.1"
resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.5.1.tgz#36513be246ab27570b1a374a5ce278bfd74370ce"
@ -5500,6 +5551,14 @@ schema-utils@^0.4.0, schema-utils@^0.4.4, schema-utils@^0.4.5:
ajv "^6.1.0"
ajv-keywords "^3.1.0"
schema-utils@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-1.0.0.tgz#0b79a93204d7b600d4b2850d1f66c2a34951c770"
dependencies:
ajv "^6.1.0"
ajv-errors "^1.0.0"
ajv-keywords "^3.1.0"
script-loader@~0.7.0:
version "0.7.2"
resolved "https://registry.yarnpkg.com/script-loader/-/script-loader-0.7.2.tgz#2016db6f86f25f5cf56da38915d83378bb166ba7"
@ -5671,6 +5730,13 @@ source-map-support@^0.5.6:
buffer-from "^1.0.0"
source-map "^0.6.0"
source-map-support@~0.5.6:
version "0.5.9"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f"
dependencies:
buffer-from "^1.0.0"
source-map "^0.6.0"
source-map-url@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
@ -5742,11 +5808,11 @@ sshpk@^1.7.0:
jsbn "~0.1.0"
tweetnacl "~0.14.0"
ssri@^5.2.4:
version "5.3.0"
resolved "https://registry.yarnpkg.com/ssri/-/ssri-5.3.0.tgz#ba3872c9c6d33a0704a7d71ff045e5ec48999d06"
ssri@^6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"
dependencies:
safe-buffer "^5.1.1"
figgy-pudding "^3.5.1"
stack-utils@^1.0.1:
version "1.0.1"
@ -5953,6 +6019,27 @@ tar@^4:
safe-buffer "^5.1.2"
yallist "^3.0.2"
terser-webpack-plugin@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.1.0.tgz#cf7c25a1eee25bf121f4a587bb9e004e3f80e528"
dependencies:
cacache "^11.0.2"
find-cache-dir "^2.0.0"
schema-utils "^1.0.0"
serialize-javascript "^1.4.0"
source-map "^0.6.1"
terser "^3.8.1"
webpack-sources "^1.1.0"
worker-farm "^1.5.2"
terser@^3.8.1:
version "3.8.2"
resolved "https://registry.yarnpkg.com/terser/-/terser-3.8.2.tgz#48b880f949f8d038aca4dfd00a37c53d96ecf9fb"
dependencies:
commander "~2.17.1"
source-map "~0.6.1"
source-map-support "~0.5.6"
test-exclude@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.2.1.tgz#dfa222f03480bca69207ca728b37d74b45f724fa"
@ -6101,13 +6188,6 @@ ua-parser-js@^0.7.9:
version "0.7.18"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.18.tgz#a7bfd92f56edfb117083b69e31d2aa8882d4b1ed"
uglify-es@^3.3.4:
version "3.3.9"
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677"
dependencies:
commander "~2.13.0"
source-map "~0.6.1"
uglify-js@^2.6, uglify-js@^2.6.1:
version "2.8.29"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
@ -6121,19 +6201,6 @@ uglify-to-browserify@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
uglifyjs-webpack-plugin@^1.2.4:
version "1.2.7"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.7.tgz#57638dd99c853a1ebfe9d97b42160a8a507f9d00"
dependencies:
cacache "^10.0.4"
find-cache-dir "^1.0.0"
schema-utils "^0.4.5"
serialize-javascript "^1.4.0"
source-map "^0.6.1"
uglify-es "^3.3.4"
webpack-sources "^1.1.0"
worker-farm "^1.5.2"
union-value@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4"