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

Support Wasm Component Model #33

Open
DougAnderson444 opened this issue Jun 19, 2023 · 5 comments
Open

Support Wasm Component Model #33

DougAnderson444 opened this issue Jun 19, 2023 · 5 comments

Comments

@DougAnderson444
Copy link

@bjorn3 as I mentioned here bytecodealliance/jco#42 (comment) I think the way to go about supporting the component model is:

  1. Generate the files, imports and exports using the wasm-compiled js-component-bindgen-component
import { generate } from './js-component-bindgen-component.js`
let { files, imports, exports } = generate(component, opts);
  1. Write a Rollup plugin that takes the 3 generated bytes above and bundles them into an output.
  2. Consumers can then take the bundled output do things like inject it into <head><script>... so it can be used by the window.
@bjorn3
Copy link
Owner

bjorn3 commented Jun 19, 2023

Ideally it would be possible to do everything in the browser such that a separate build step for users is not necessary. If that is not feasible a rollup plugin would be fine with me. I don't have any experience with rollup though so I don't know how easy it would be for me to implement.

@bjorn3
Copy link
Owner

bjorn3 commented Jun 19, 2023

By the way do you know if browsers intend to support the component model in the (near) future?

@DougAnderson444
Copy link
Author

Ideally it would be possible to do everything in the browser such that a separate build step for users is not necessary. If that is not feasible a rollup plugin would be fine with me. I don't have any experience with rollup though so I don't know how easy it would be for me to implement.

It can indeed all be done in the browser. Rollup can actually be run in the browser too! (Not many people know this).

So what we would have is: Import the component bytes, get loaded JS in the same page. No (non-browser) build step.

I'll see if I can whip up a Rollup plugin for these files.

@DougAnderson444
Copy link
Author

So I wrote the Rollup Plugin 🚀

https://github.com/DougAnderson444/rollup-plugin-wit-component

Needs a bit of cleanup, polish, and a demo to show how to import a *.component.wasm into the browser and use the functions. But it works =)

@DougAnderson444
Copy link
Author

By the way do you know if browsers intend to support the component model in the (near) future?

I do not know. I suspect the answer is "not anytime soon."

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

2 participants