Skip to content
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
9 changes: 5 additions & 4 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"dependencies": {
"acorn": "^8.15.0",
"acorn-import-phases": "^1.0.4",
"google-closure-compiler": "20260429.0.0",
"html-minifier-terser": "7.2.0"
},
Expand Down
9 changes: 9 additions & 0 deletions test/js_optimizer/JSDCE-sourcePhaseImports-output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import source wasmModule from "./foo.wasm";

import source otherModule from "./bar.wasm";

function use() {
return [ wasmModule, otherModule ];
}

use();
11 changes: 11 additions & 0 deletions test/js_optimizer/JSDCE-sourcePhaseImports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Source-phase imports (https://github.com/tc39/proposal-source-phase-imports).
// The acorn optimizer must parse these via the acorn-import-phases plugin and
// preserve the `source` phase keyword through the terser from_mozilla_ast ->
// print round-trip used at -O2+.
import source wasmModule from './foo.wasm';
import source otherModule from './bar.wasm';

function use() {
return [wasmModule, otherModule];
}
use();
9 changes: 7 additions & 2 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,15 @@ def test_esm(self, args):
self.assertContained('Hello, world!', self.run_js('hello_world.mjs'))

@requires_node_25
def test_esm_source_phase_imports(self):
@parameterized({
'': ([],),
'O3': (['-O3'],),
})
def test_esm_source_phase_imports(self, args):
self.node_args += ['--experimental-wasm-modules', '--no-warnings']
self.run_process([EMCC, '-o', 'hello_world.mjs', '-sSOURCE_PHASE_IMPORTS',
'--extern-post-js', test_file('modularize_post_js.js'),
test_file('hello_world.c')])
test_file('hello_world.c')] + args)
self.assertContained('import source wasmModule from', read_file('hello_world.mjs'))
self.assertContained('Hello, world!', self.run_js('hello_world.mjs'))

Expand Down Expand Up @@ -3012,6 +3016,7 @@ def test_extern_prepost(self):
'minifyGlobals': (['minifyGlobals'],),
'minifyLocals': (['minifyLocals'],),
'JSDCE': (['JSDCE', '--export-es6'],),
'JSDCE-sourcePhaseImports': (['JSDCE', '--export-es6'],),
'JSDCE-hasOwnProperty': (['JSDCE'],),
'JSDCE-defaultArg': (['JSDCE'],),
'JSDCE-fors': (['JSDCE'],),
Expand Down
2 changes: 1 addition & 1 deletion third_party/terser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version published in npm.
This `terser.js` bundle in this directory was built from our fork of terser
which lives at: https://github.com/emscripten-core/terser/

The current patches are stored in the `emscripten_patches_v4.8.0` branch.
The current patches are stored in the `emscripten_patches_v5.18.2` branch.

To make changes to this code please submit patches to
https://github.com/emscripten-core/terser/ and then re-create this bundle
Expand Down
Loading
Loading