Skip to content

Commit

Permalink
Replace uglify-es with terser
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
alopezsanchez authored and mathiasbynens committed Sep 5, 2018
1 parent d9abe27 commit 48649a5
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 57 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@ i.e. like this:
$ node dist/cli.js
Running Web Tooling Benchmark v0.5.1…
-------------------------------------
acorn: 6.94 runs/s
babel: 7.45 runs/s
babel-minify: 6.66 runs/s
babylon: 6.26 runs/s
buble: 4.07 runs/s
chai: 14.33 runs/s
coffeescript: 5.95 runs/s
espree: 2.09 runs/s
esprima: 4.13 runs/s
jshint: 8.84 runs/s
lebab: 7.07 runs/s
postcss: 5.35 runs/s
prepack: 5.58 runs/s
prettier: 6.19 runs/s
source-map: 7.63 runs/s
typescript: 8.59 runs/s
uglify-es: 13.69 runs/s
uglify-js: 4.59 runs/s
acorn: 6.11 runs/s
babel: 5.59 runs/s
babel-minify: 6.79 runs/s
babylon: 5.48 runs/s
buble: 3.31 runs/s
chai: 10.49 runs/s
coffeescript: 4.72 runs/s
espree: 3.44 runs/s
esprima: 4.27 runs/s
jshint: 6.38 runs/s
lebab: 5.76 runs/s
postcss: 4.35 runs/s
prepack: 5.07 runs/s
prettier: 4.36 runs/s
source-map: 6.66 runs/s
terser: 10.87 runs/s
typescript: 6.62 runs/s
uglify-js: 3.48 runs/s
-------------------------------------
Geometric mean: 6.38 runs/s
Geometric mean: 5.45 runs/s
```

Or you open a web browser and point it to `dist/index.html`, or you can use one
Expand Down
10 changes: 6 additions & 4 deletions docs/in-depth.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ This benchmark stresses the source-map tool on both parsing and serializing a
variety of different source maps, including the [Preact](http://preactjs.com)
8.2.5 source map.

## terser

[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`.

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.

## typescript

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

This benchmark runs the UglifyJS minifier on the (concatenated) JavaScript source for
the ES2015 test in the [Lodash](https://lodash.com) module.

## uglify-es

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.
47 changes: 28 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"main": "src/cli.js",
"scripts": {
"benchmark": "node dist/cli.js",
"build:uglify-es-bundled": "node node_modules/uglify-es/bin/uglifyjs -b preamble=\"'const UglifyJS = module.exports = {};'\" --self > build/uglify-es-bundled.js",
"build:terser-bundled": "node node_modules/terser/bin/uglifyjs -b preamble=\"'const Terser = module.exports = {};'\" --self > build/terser-bundled.js",
"build:uglify-js-bundled": "node node_modules/uglify-js/bin/uglifyjs -b preamble=\"'const UglifyJS = module.exports = {};'\" --self > build/uglify-js-bundled.js",
"build": "webpack",
"postinstall": "npm run build:uglify-es-bundled && npm run build:uglify-js-bundled && npm run build",
"postinstall": "npm run build:terser-bundled && npm run build:uglify-js-bundled && npm run build",
"precommit": "node tools/hooks/pre-commit.js && lint-staged",
"test": "jest",
"update-lock": "npm install --package-lock"
Expand Down Expand Up @@ -59,8 +59,8 @@
"prettier": "1.9.2",
"source-map": "0.6.1",
"string-align": "^0.2.0",
"terser": "3.8.2",
"typescript": "2.7.2",
"uglify-es": "3.3.9",
"uglify-js": "3.3.16",
"virtualfs": "^2.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/cli-flags-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const targetList = new Set([
"prepack",
"prettier",
"source-map",
"terser",
"typescript",
"uglify-es",
"uglify-js"
]);

Expand Down
8 changes: 4 additions & 4 deletions src/uglify-es-benchmark.js → src/terser-benchmark.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

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

const payloads = [
Expand All @@ -16,10 +16,10 @@ const payloads = [
}));

module.exports = {
name: "uglify-es",
name: "terser",
fn() {
return payloads.map(({ payload, options }) =>
UglifyJS.minify(payload, options)
Terser.minify(payload, options)
);
}
};
7 changes: 7 additions & 0 deletions src/terser-benchmark.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

const terserBenchmark = require("./terser-benchmark");

it("terser-benchmark runs to completion", () => void terserBenchmark.fn());
7 changes: 0 additions & 7 deletions src/uglify-es-benchmark.test.js

This file was deleted.

0 comments on commit 48649a5

Please sign in to comment.