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

Integration with import assertions #42

Open
littledan opened this issue Nov 11, 2020 · 4 comments
Open

Integration with import assertions #42

littledan opened this issue Nov 11, 2020 · 4 comments

Comments

@littledan
Copy link
Collaborator

Now that import assertions are Stage 3, we have to decide how they will integrate with Wasm/ESM integration. There are two aspects of this:

  • When importing a Wasm module from JS, does it need an explicit assert { type: "wasm" } or is this OK to be implicit (given that, currently, JS and Wasm run at the same privilege level Should WebAssembly be at the same "privilege level" as JS? #41)?
  • WebAssembly modules will need a custom section which somehow note the import assertions. We'll want to design this custom section format to be future-proof to possible expansions of the import assertion grammar, and the possible creation of "evaluator" attributes. (previous mention)
@devsnek
Copy link
Member

devsnek commented Nov 11, 2020

does it need an explicit assert { type: "wasm" }

I think need should be no, but an implementation should feel free to add that.

@littledan
Copy link
Collaborator Author

I guess there are two questions:

  • How the integration should work in HTML
  • How the integration should work in other environments

In HTML, implementations don't really have the freedom to add things--HTML is governed by a standard. We could make this mandatory, optional, or always missing, when used in HTML. But we won't let each individual browser choose its semantics.

Other environments can sort of do whatever they want--they don't have to align with HTML, or they can align but also permit looser behavior.

@annevk
Copy link
Member

annevk commented Nov 30, 2020

Do we envision the capabilities of Wasm and JS to diverge? If so, requiring an assertion might be prudent.

@Ms2ger
Copy link
Collaborator

Ms2ger commented Nov 19, 2021

When importing a Wasm module from JS, I don't think there's any reason to allow an import assertion, since the Wasm module can import other JS anyway. It remains possible to forbid that by using WebAssembly.instantiate() directly.

If we'd ever want to add a feature where JS imports Wasm that can't then import JS (though I don't see why we'd want to do that), we could use an import assertion for that - and it would be unfortunate if the obvious string was already taken here.

Import assertions for wasm importing json (for example) are an orthogonal issue, which I believe needs some work still.

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

4 participants