Emit source phase import for MODULARIZE=instance#27237
Merged
sbc100 merged 2 commits intoJul 9, 2026
Merged
Conversation
sbc100
reviewed
Jul 2, 2026
guybedford
force-pushed
the
esm-source-phase-instance
branch
2 times, most recently
from
July 9, 2026 01:22
ef110e9 to
5535e45
Compare
sbc100
approved these changes
Jul 9, 2026
In MODULARIZE=instance mode the modularize() wrapper is not applied, so the top-level 'import source wasmModule' statement in src/modularize.js was never emitted, leaving preamble.js referencing an undefined wasmModule. Emit the source phase import from preamble.js (module scope in instance mode), next to where wasmModule is declared and used, so that -sSOURCE_PHASE_IMPORTS works alongside -sMODULARIZE=instance/EXPORT_ES6.
guybedford
force-pushed
the
esm-source-phase-instance
branch
from
July 9, 2026 18:03
5535e45 to
ca8df65
Compare
sbc100
approved these changes
Jul 9, 2026
sbc100
enabled auto-merge (squash)
July 9, 2026 18:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes
-sSOURCE_PHASE_IMPORTSwork together with-sMODULARIZE=instance(andEXPORT_ES6).In
MODULARIZE=instancemode the output is not wrapped bymodularize(), so the top-levelimport source wasmModulestatement thatsrc/modularize.jsnormally emits was never produced. This leftpreamble.jsreferencing an undefinedwasmModule, breaking source phase imports in instance mode.Since instance mode output is itself a module, the source phase import is now emitted directly from
postamble.jsat module scope when both settings are enabled:Adds a parameterized
test_esm_source_phase_imports_instance(default and-O3) that builds with-sSOURCE_PHASE_IMPORTS -sMODULARIZE=instanceand verifies the import is emitted and the module runs.