Support JS libraries self-registering their exports via EXPORTED_FUNCTIONS - #27436
Open
guybedford wants to merge 2 commits into
Open
Support JS libraries self-registering their exports via EXPORTED_FUNCTIONS#27436guybedford wants to merge 2 commits into
guybedford wants to merge 2 commits into
Conversation
…TIONS JS library code can already mutate the compile-time EXPORTED_FUNCTIONS set at library load time, which under MODULARIZE=instance causes jsifier to emit the symbol with an `export` declaration. This makes that flow fully work by forwarding the final EXPORTED_FUNCTIONS set back from the JS compiler so the linker can derive which JS library symbols were exported, and have the WASM_ESM_INTEGRATION wrapper re-export them. This is used by binding layers (e.g. wasm-bindgen) that define a public JS API surface distinct from the wasm export names, registering it from their generated JS library.
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 implements support for JS libraries adding their own symbols to
EXPORTED_FUNCTIONSat library load time, split out from #27208 as requested in review there.JS library code can already mutate the compile-time
EXPORTED_FUNCTIONSset (it is exposed to library code as aSet), which underMODULARIZE=instancecauses jsifier to emit the symbol with anexportdeclaration. What was missing is the linker knowing about those additions:EXPORTED_FUNCTIONSset is now forwarded back from the JS compiler inFORWARDED_DATA, so the linker can derive which JS library symbols were exported.WASM_ESM_INTEGRATIONwrapper re-exports those symbols from the support module.This is a requirement for wasm-bindgen's binding layers that define a public JS API surface distinct from the wasm export names (e.g. exported JS classes and namespaces), registering it from their generated JS library:
Test coverage is included in test_jslib.py for both
MODULARIZE=instanceandWASM_ESM_INTEGRATIONoutput modes, where theWASM_ESM_INTEGRATIONvariant fails without this change.Made with AI assistance under my review