Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebAssembly source phase imports #56056

Open
legendecas opened this issue Nov 28, 2024 · 3 comments
Open

WebAssembly source phase imports #56056

legendecas opened this issue Nov 28, 2024 · 3 comments
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. wasm Issues and PRs related to WebAssembly. web-standards Issues and PRs related to Web APIs

Comments

@legendecas
Copy link
Member

legendecas commented Nov 28, 2024

TC39 proposal source phase imports reached to stage 3 and has been implemented in V8 (starting from M131).

import source FooModule from "./foo.wasm";
FooModule instanceof WebAssembly.Module; // true

The feature requires Node.js integration to support WebAssembly source phase imports. TLDR, if a SourceTextModule imports a source-phase WebAssembly module, create a module source object with v8::WasmModuleObject::Compile and return the WebAssembly.Module object from v8::Module::ResolveSourceCallback, and v8::HostImportModuleWithPhaseDynamicallyCallback.

See design doc for details.

WPT: https://github.com/web-platform-tests/wpt/blob/master/wasm/webapi/esm-integration/source-phase.tentative.html

/cc @guybedford

@legendecas legendecas added wasm Issues and PRs related to WebAssembly. web-standards Issues and PRs related to Web APIs esm Issues and PRs related to the ECMAScript Modules implementation. labels Nov 28, 2024
@guybedford
Copy link
Contributor

This should ideally be implemented along with the ESM instance imports and should likely also go with unflagging --experimental-wasm-modules.

@bakkot
Copy link

bakkot commented Dec 1, 2024

There's not much reason to care about ESM instance imports without also having worker_threads support instantiating workers from a ModuleSource - which is worth doing, but is probably a bigger topic than wasm source phase imports (which are immediately useful).

@sbc100
Copy link

sbc100 commented Dec 3, 2024

Emscripten would love to start using this feature as soon as its available: emscripten-core/emscripten#23047

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. wasm Issues and PRs related to WebAssembly. web-standards Issues and PRs related to Web APIs
Projects
None yet
Development

No branches or pull requests

4 participants