Skip to content

Commit 08e2361

Browse files
committed
Update terser to v5.18.2 and verify optional chaining support
Fixes: #15827
1 parent 7205fae commit 08e2361

7 files changed

+30976
-21640
lines changed

test/optimizer/applyImportAndExportNameChanges2-output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ var imports = {
264264

265265
var ___errno_location, _llvm_bswap_i32, _main, _memcpy, _memset, dynCall_ii, dynCall_iiii;
266266

267-
WebAssembly.instantiate(Module["wasm"], imports).then(output => {
267+
WebAssembly.instantiate(Module["wasm"], imports).then((output => {
268268
var asm = output.instance.exports;
269269
___errno_location = asm["j"];
270270
_llvm_bswap_i32 = asm["k"];
@@ -275,4 +275,4 @@ WebAssembly.instantiate(Module["wasm"], imports).then(output => {
275275
dynCall_iiii = asm["p"];
276276
initRuntime(asm);
277277
ready();
278-
});
278+
}));

test/optimizer/minimal-runtime-applyDCEGraphRemovals-output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ var wasmImports = {
55
"save2": 2
66
};
77

8-
WebAssembly.instantiate(Module["wasm"], imports).then(output => {
8+
WebAssembly.instantiate(Module["wasm"], imports).then((output => {
99
asm = output.instance.exports;
1010
expD1 = asm["expD1"];
1111
expD2 = asm["expD2"];
1212
expD3 = asm["expD3"];
1313
initRuntime(asm);
1414
ready();
15-
});
15+
}));
1616

1717
expD1;
1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
15050
1+
15052

third_party/terser/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Bundled version of terser 4.1.0 with emscripten patches
2-
=======================================================
1+
Bundled version of terser 5.18.2 with emscripten patches
2+
========================================================
33

44
We maintain a few downstream patches to terser which means we can't use the
55
version published in npm.
@@ -13,5 +13,5 @@ To make changes to this code please submit patches to
1313
https://github.com/emscripten-core/terser/ and then re-create this bundle
1414
using the following steps:
1515

16-
$ npx rollup -c
17-
$ cp dist/bundle.js $EMSCRIPTEN_ROOT/third_party/terser/terser.js
16+
$ CI=1 npx rollup -c
17+
$ cp dist/bundle.min.js $EMSCRIPTEN_ROOT/third_party/terser/terser.js

third_party/terser/terser.js

Lines changed: 30951 additions & 21610 deletions
Large diffs are not rendered by default.

tools/acorn-optimizer.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,24 +1945,16 @@ function reattachComments(ast, comments) {
19451945
symbols[j].start.comments_before = [];
19461946
}
19471947
symbols[j].start.comments_before.push(
1948-
new terser.AST_Token({
1949-
end: undefined,
1950-
quote: undefined,
1951-
raw: undefined,
1952-
file: '0',
1953-
comments_after: undefined,
1954-
comments_before: undefined,
1955-
nlb: false,
1956-
endpos: undefined,
1957-
endcol: undefined,
1958-
endline: undefined,
1959-
pos: undefined,
1960-
col: undefined,
1961-
line: undefined,
1962-
value: comments[i].value,
1963-
type: comments[i].type == 'Line' ? 'comment' : 'comment2',
1964-
flags: 0,
1965-
})
1948+
new terser.AST_Token(
1949+
comments[i].type == 'Line' ? 'comment' : 'comment2',
1950+
comments[i].value,
1951+
undefined,
1952+
undefined,
1953+
false,
1954+
undefined,
1955+
undefined,
1956+
'0'
1957+
)
19661958
);
19671959
}
19681960
}

tools/unsafe_optimizations.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function optPassMergeVarInitializationAssignments(ast) {
223223
}
224224

225225
function runOnJsText(js, pretty = false) {
226-
const ast = acorn.parse(js, {ecmaVersion: 6});
226+
const ast = acorn.parse(js, {ecmaVersion: 2020});
227227

228228
optPassSimplifyModuleInitialization(ast);
229229
optPassRemoveRedundantOperatorNews(ast);
@@ -255,7 +255,7 @@ let numTestFailures = 0;
255255
function test(input, expected) {
256256
const observed = runOnJsText(input);
257257
if (observed != expected) {
258-
console.error(`Input: ${input}\nobserved: ${observed}\nexpected: ${expected}\n`);
258+
console.error(`ERROR: Input: ${input}\nobserved: ${observed}\nexpected: ${expected}\n`);
259259
++numTestFailures;
260260
} else {
261261
console.log(`OK: ${input} -> ${expected}`);
@@ -279,7 +279,7 @@ function runTests() {
279279
test("new function(a) {new TextDecoder(a);}('utf8');", '');
280280
test(
281281
'WebAssembly.instantiate(c.wasm,{}).then((a) => {new Int8Array(b);});',
282-
'WebAssembly.instantiate(c.wasm,{}).then(a=>{});'
282+
'WebAssembly.instantiate(c.wasm,{}).then((a=>{}));'
283283
);
284284
test('let x=new Uint16Array(a);', 'let x=new Uint16Array(a);');
285285

@@ -305,6 +305,9 @@ function runTests() {
305305
// Test that arrays containing nulls don't cause issues
306306
test('[,];', '[,];');
307307

308+
// Test optional chaining operator
309+
test('console?.log("");', 'console?.log("");');
310+
308311
process.exit(numTestFailures);
309312
}
310313

0 commit comments

Comments
 (0)