Skip to content

[js-api] Skip string constant imports in ESM integration - #124

Open
guybedford wants to merge 2 commits into
mainfrom
esm-string-constants
Open

guybedford wants to merge 2 commits into
mainfrom
esm-string-constants

Conversation

@guybedford

Copy link
Copy Markdown
Collaborator

#115 landed support for importing a given builtin name for a string constant, but the name was not remove from the computed set of imports like other builtins.

This fixes that sso that [[ImportedStringModule]] is excluded alongside the builtins in the same way so it is not treated as a normal import.

Tests are added to verify the behavior.

The ESM integration sets the imported string module to
"wasm:js/string-constants" but never checked it when computing
requested modules or linking imports, so a string constant import
would have been resolved as a module specifier. Add an
[[ImportedStringModule]] check alongside the existing builtin check
in parse and ExecuteModule.

Adds ESM and source phase tests for string constants imported from
wasm:js/string-constants.
@guybedford

Copy link
Copy Markdown
Collaborator Author

@chicoxyzzy while you have the context, I'd value your sign-off on this correctness fix if you have a moment.

@chicoxyzzy chicoxyzzy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parse-time requestedModules skip looks right. String constants stay out of the specifier set the same way builtins already do.

HostGetModuleSourceModuleRecord still puts wasm:js/string-constants and wasm:js-string into requestedModules. I am not sure whether that path needs the same skip.

@guybedford

Copy link
Copy Markdown
Collaborator Author

@chicoxyzzy good catch thanks, yes that should be included as well. I've abstracted a shared helper for this now to ensure all codepaths stay together.

Will land this fix further tomorrow, unless there's further feedback.

@chicoxyzzy

Copy link
Copy Markdown
Member

Reserved wasm: / wasm-js: LinkErrors now run after the builtin and string-constant skip. A string-constant field named wasm:foo would no longer throw.

Firefox and WebKit still check every import field first. V8 only sees WebAssembly.Module.imports(), which already dropped those. Just checking if that's intended.

@guybedford

Copy link
Copy Markdown
Collaborator Author

Yes, intended, the prefix reservation is only for public imports. User string consts starting with wasm: or wasm-js: can be supported fine.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants