Skip to content
Open
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
7 changes: 6 additions & 1 deletion src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ if (!globalThis.WebAssembly) {

// Wasm globals

#if SHARED_MEMORY
#if SOURCE_PHASE_IMPORTS && MODULARIZE == 'instance'
// In MODULARIZE=instance mode the output is itself an ES module (it is not
// wrapped by modularize.js), so the source phase import is emitted here at
// module scope, next to where wasmModule is used.
import source wasmModule from './{{{ WASM_BINARY_FILE }}}';
#elif SHARED_MEMORY
// For sending to workers.
var wasmModule;
#endif // SHARED_MEMORY
Expand Down
2 changes: 1 addition & 1 deletion test/codesize/test_codesize_minimal_O0.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// globalThis because older browsers might not have globalThis defined.

// We skip the node version checking when running on Bun/Deno since the node
// version they report is not completely.
// version they report doesn't seem to be useful.
if (typeof process !== 'undefined' && !process.versions?.bun && typeof Deno == "undefined") {
var currentNodeVersion = process.versions?.node ? humanReadableVersionToPacked(process.versions.node) : TARGET_NOT_SUPPORTED;
if (currentNodeVersion < 180300) {
Expand Down
12 changes: 6 additions & 6 deletions test/codesize/test_unoptimized_code_size.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"hello_world.js": 56114,
"hello_world.js.gz": 17666,
"hello_world.js": 56122,
"hello_world.js.gz": 17671,
"hello_world.wasm": 15115,
"hello_world.wasm.gz": 7464,
"no_asserts.js": 25585,
"no_asserts.js.gz": 8688,
"no_asserts.wasm": 12229,
"no_asserts.wasm.gz": 6004,
"strict.js": 53216,
"strict.js.gz": 16637,
"strict.js": 53224,
"strict.js.gz": 16642,
"strict.wasm": 15115,
"strict.wasm.gz": 7461,
"total": 177374,
"total_gz": 63920
"total": 177390,
"total_gz": 63930
}
12 changes: 12 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,18 @@ def test_esm_source_phase_imports(self, args):
self.assertContained('import source wasmModule from', read_file('hello_world.mjs'))
self.assertContained('Hello, world!', self.run_js('hello_world.mjs'))

@requires_node_25
@parameterized({
'': ([],),
'O3': (['-O3'],),
})
def test_esm_source_phase_imports_instance(self, args):
self.set_setting('SOURCE_PHASE_IMPORTS')
self.set_setting('MODULARIZE', 'instance')
self.cflags += ['-Wno-experimental'] + args
self.do_runf('hello_world.c', 'Hello, world!')
self.assertContained('import source wasmModule from', read_file(self.output_name('hello_world')))

@parameterized({
'': ([],),
'node': (['-sENVIRONMENT=node'],),
Expand Down
Loading