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

Tracing bindings through wasm #87

Open
ghost opened this issue Jul 6, 2024 · 1 comment
Open

Tracing bindings through wasm #87

ghost opened this issue Jul 6, 2024 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 6, 2024

Has there been any discussion of whether to trace bindings through wasm modules?

If star exports find the same name twice, they consider it ambiguous and throw.

collide

But if multiple paths lead to the same place it's not ambiguous. ESM traces bindings to detect this and load successfully.

disambiguate-value

The proposal currently drops tracing at wasm nodes. This might be surprising for devs. It means there's different load time behavior for a wasm module. If you had a dual build gadget (wasm with a JS fallback), intuitively it seems they should both work. But with reexports they don't. In a less capable environment, the JS version works. In a more capable environment, the wasm version throws an error.

gadget

export { widget } from './widget.mjs'
(func (export "widget") (import "./widget.mjs" "widget"))

Where a package reexports, this means a wasm build can't be used as a drop in replacement for the JS version.

@guybedford
Copy link
Collaborator

The concept of untyped forwarding is a difficult one to translate into Wasm in a way that is meaningful. Even with type enforcement, bindings would go through reinterpretation that effectively gives them a new identity.

In theory new constructs could be added to directly correspond to reexporting or wildcard reexporting, eg via a custom section in the Wasm binary or otherwise, but there would need to be use cases to justify anything like that, and none have yet come up.

So while exact equal parity at this level remains possible (these doors haven't been closed), it is not currently a goal given there isn't a strong use case justification.

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

No branches or pull requests

1 participant