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

Question - what happens if my JS is using a emscripten generated wasm file? #39

Open
GordonSmith opened this issue Jul 15, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@GordonSmith
Copy link

Say I have a js library that is already using an emscripten generated wasm file and I try to componentize that, given spider monkey supports wasm, can I "just" bundle the existing wasm as if it were any other resource (like a jpeg)?

@guybedford
Copy link
Collaborator

Because the component model supports core imports equally, and components can embed any number of other components or modules, in theory it should just become another core module embedded in the outer component.

There are some techniques we have in mind to support this kind of use case, it will just involve some tricks to properly handle.

So no, it's not just bundled like a jpeg, it would be wrapped specially within the component model constructs so that instead of running that Wasm on a virtual WebAssembly runtime, it would just punch through to the outer Wasm runtime and run on that.

@GordonSmith
Copy link
Author

I can imagine how this would work for components embedded in components, but will this be possible for a "emscripten generated wasm file" (which was my way of saying "not a component" or more realistically a third party wasm file, which I don't have any intimate knowledge about)?

@guybedford
Copy link
Collaborator

If I'm understanding your scenario correctly, then the answer is yes - if you are componentizing JS which depends on core Wasm, as a component, then the final component should be possible to work using these techniques since components can depend on and instantiate core wasm. And this (hypothetical) technique would automatically inline that core wasm and its bindings regardless.

It would rely on being able to statically analyze the JS to determine where Wasm is being instantiated though. But that should be possible to automatically pick up for standard instantiation code patterns in JS.

@guybedford guybedford added the enhancement New feature or request label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants