Skip to content

Commit 48649a5

Browse files
alopezsanchezmathiasbynens
authored andcommitted
Replace uglify-es with terser
`uglify-es` is no longer maintained. `terser` is a fork of `uglify-es` that retains API and CLI compatibility with `uglify-es` and `uglify-js@3`. Closes #59. Closes #61.
1 parent d9abe27 commit 48649a5

8 files changed

+68
-57
lines changed

README.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,26 @@ i.e. like this:
4949
$ node dist/cli.js
5050
Running Web Tooling Benchmark v0.5.1…
5151
-------------------------------------
52-
acorn: 6.94 runs/s
53-
babel: 7.45 runs/s
54-
babel-minify: 6.66 runs/s
55-
babylon: 6.26 runs/s
56-
buble: 4.07 runs/s
57-
chai: 14.33 runs/s
58-
coffeescript: 5.95 runs/s
59-
espree: 2.09 runs/s
60-
esprima: 4.13 runs/s
61-
jshint: 8.84 runs/s
62-
lebab: 7.07 runs/s
63-
postcss: 5.35 runs/s
64-
prepack: 5.58 runs/s
65-
prettier: 6.19 runs/s
66-
source-map: 7.63 runs/s
67-
typescript: 8.59 runs/s
68-
uglify-es: 13.69 runs/s
69-
uglify-js: 4.59 runs/s
52+
acorn: 6.11 runs/s
53+
babel: 5.59 runs/s
54+
babel-minify: 6.79 runs/s
55+
babylon: 5.48 runs/s
56+
buble: 3.31 runs/s
57+
chai: 10.49 runs/s
58+
coffeescript: 4.72 runs/s
59+
espree: 3.44 runs/s
60+
esprima: 4.27 runs/s
61+
jshint: 6.38 runs/s
62+
lebab: 5.76 runs/s
63+
postcss: 4.35 runs/s
64+
prepack: 5.07 runs/s
65+
prettier: 4.36 runs/s
66+
source-map: 6.66 runs/s
67+
terser: 10.87 runs/s
68+
typescript: 6.62 runs/s
69+
uglify-js: 3.48 runs/s
7070
-------------------------------------
71-
Geometric mean: 6.38 runs/s
71+
Geometric mean: 5.45 runs/s
7272
```
7373

7474
Or you open a web browser and point it to `dist/index.html`, or you can use one

docs/in-depth.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ This benchmark stresses the source-map tool on both parsing and serializing a
187187
variety of different source maps, including the [Preact](http://preactjs.com)
188188
8.2.5 source map.
189189

190+
## terser
191+
192+
[terser](https://github.com/fabiosantoscode/terser) is a fork of `uglify-es` that retains API and CLI compatibility with `uglify-es` and `uglify-js@3`.
193+
194+
This benchmark stresses the new ES2015-and-beyond minifier on the (concatenated) JavaScript source for the ES2015 test in the [Speedometer](https://browserbench.org/Speedometer) 2.0 benchmark.
195+
190196
## typescript
191197

192198
[TypeScript](https://github.com/Microsoft/TypeScript) is a language for
@@ -205,7 +211,3 @@ bundles.
205211

206212
This benchmark runs the UglifyJS minifier on the (concatenated) JavaScript source for
207213
the ES2015 test in the [Lodash](https://lodash.com) module.
208-
209-
## uglify-es
210-
211-
This benchmark stresses the new ES2015 and beyond minifier on the (concatenated) JavaScript source for the ES2015 test in the [Speedometer](https://browserbench.org/Speedometer) 2.0 benchmark.

package-lock.json

+28-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"main": "src/cli.js",
77
"scripts": {
88
"benchmark": "node dist/cli.js",
9-
"build:uglify-es-bundled": "node node_modules/uglify-es/bin/uglifyjs -b preamble=\"'const UglifyJS = module.exports = {};'\" --self > build/uglify-es-bundled.js",
9+
"build:terser-bundled": "node node_modules/terser/bin/uglifyjs -b preamble=\"'const Terser = module.exports = {};'\" --self > build/terser-bundled.js",
1010
"build:uglify-js-bundled": "node node_modules/uglify-js/bin/uglifyjs -b preamble=\"'const UglifyJS = module.exports = {};'\" --self > build/uglify-js-bundled.js",
1111
"build": "webpack",
12-
"postinstall": "npm run build:uglify-es-bundled && npm run build:uglify-js-bundled && npm run build",
12+
"postinstall": "npm run build:terser-bundled && npm run build:uglify-js-bundled && npm run build",
1313
"precommit": "node tools/hooks/pre-commit.js && lint-staged",
1414
"test": "jest",
1515
"update-lock": "npm install --package-lock"
@@ -59,8 +59,8 @@
5959
"prettier": "1.9.2",
6060
"source-map": "0.6.1",
6161
"string-align": "^0.2.0",
62+
"terser": "3.8.2",
6263
"typescript": "2.7.2",
63-
"uglify-es": "3.3.9",
6464
"uglify-js": "3.3.16",
6565
"virtualfs": "^2.1.0"
6666
},

src/cli-flags-helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const targetList = new Set([
1414
"prepack",
1515
"prettier",
1616
"source-map",
17+
"terser",
1718
"typescript",
18-
"uglify-es",
1919
"uglify-js"
2020
]);
2121

src/uglify-es-benchmark.js renamed to src/terser-benchmark.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// Copyright 2017 the V8 project authors. All rights reserved.
1+
// Copyright 2018 the V8 project authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
const UglifyJS = require("../build/uglify-es-bundled");
5+
const Terser = require("../build/terser-bundled");
66
const fs = require("fs");
77

88
const payloads = [
@@ -16,10 +16,10 @@ const payloads = [
1616
}));
1717

1818
module.exports = {
19-
name: "uglify-es",
19+
name: "terser",
2020
fn() {
2121
return payloads.map(({ payload, options }) =>
22-
UglifyJS.minify(payload, options)
22+
Terser.minify(payload, options)
2323
);
2424
}
2525
};

src/terser-benchmark.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2018 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
const terserBenchmark = require("./terser-benchmark");
6+
7+
it("terser-benchmark runs to completion", () => void terserBenchmark.fn());

src/uglify-es-benchmark.test.js

-7
This file was deleted.

0 commit comments

Comments
 (0)