Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(terser): call terser binary instead of uglifyjs #1360

Merged
merged 2 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"sinon": "^7.3.2",
"source-map": "^0.7.3",
"source-map-support": "0.5.9",
"terser": "3.17.0",
"terser": "^4.4.0",
"testy": "file:./tools/npm_packages/testy",
"tmp": "0.1.0",
"tsickle": "0.33.1",
Expand Down
13 changes: 10 additions & 3 deletions packages/terser/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,15 @@ function main() {
const output = argv[outputArgIndex + 1];
const residual = argv.slice(outputArgIndex + 2);

// user override for the terser binary location. used in testing.
const terserBinary = process.env.TERSER_BINARY || require.resolve('terser/bin/uglifyjs')
// Allow for user to override terser binary for testing.
let terserBinary = process.env.TERSER_BINARY;
try {
// If necessary, get the new `terser` binary, added for >=4.3.0
terserBinary = terserBinary || require.resolve('terser/bin/terser');
} finally {
// If necessary, get the old `uglifyjs` binary from <4.3.0
terserBinary = terserBinary || require.resolve('terser/bin/uglifyjs');
}
// choose a default concurrency of the number of cores -1 but at least 1.

log_verbose(`Running terser/index.js
Expand All @@ -171,7 +178,7 @@ function main() {
if (!inputs.find(isDirectory) && inputs.length) {
// Inputs were only files
// Just use terser CLI exactly as it works outside bazel
require(terserBinary || 'terser/bin/uglifyjs');
require(terserBinary);

} else if (inputs.length > 1) {
// We don't know how to merge multiple input dirs to one output dir
Expand Down