BridgeJS: Use indirect _exports lookup in wrap functions#642
Merged
kateinoigakukun merged 1 commit intoswiftwasm:mainfrom Feb 18, 2026
Merged
Conversation
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.
Overview
The
bjs_*_wrapfunctions generated inaddImportsreference class names directly:These classes are defined later inside
createExports, soGreeterisn't in scope whenaddImportsruns. It works at runtime because the callback only executes aftercreateExportshas been called, but it's a static scope violation - any linter withno-undefenabled will flag it, and it's flagged by default in most ESLint configs. We hit this when linting vendored BridgeJS output downstream.The codebase already handles this elsewhere.
JSGlueGen.swifthas ahasDirectAccessToSwiftClassflag that controls whether to use the class directly or go through_exports['ClassName']. The import-side functions inaddImportsdon't have direct access, so they should use the indirect lookup - same as the other import-side references already do (e.g.bjs_jsRoundTripGreeteron the same snapshot file already uses_exports['Greeter'].__construct()).Before (SwiftClass.js snapshot):
After: