Stream: wasmtime

Topic: Run wasmtime in browser for earlier component-model support?


view this post on Zulip James Mart (Jan 31 2024 at 02:24):

Possibly a silly question here, but:

I already know that it's possible to write a webassembly component and use jco transpile to generate a core wasm with bindings that can easily be executed in the browser.

Would it also be possible to compile wasmtime itself to a core wasm, execute it in the browser, and then have the embedded wasmtime run wasm components directly without transpilation? If so, would that be a way to take advantage of wasmtime's support for component-model features (e.g. futures/streams) that presumably will arrive before support comes in the native browser wasm runtimes?

view this post on Zulip Alex Crichton (Jan 31 2024 at 02:28):

While theoretically possible Wasmtime is definitely not built for this today and it would require quite a lot of surgery to get this working. It's probaby safe to say that jco is your best bet for now. One thing of note is that you can embed jco itself on a web page and effectively eval the output which is more-or-less what loading wasmtime would look like

view this post on Zulip James Mart (Jan 31 2024 at 02:41):

It's probaby safe to say that jco is your best bet for now.

If I am understanding correctly, then there is still a downside to doing it that way, though - for example, when futures and streams are first supported in preview3, I assume BCA runtimes like wasmtime will be the first to support it. But if I'm only executing my transpiled components in a native browser runtime, then I will have to wait until each browser runtime adds support. Is this correct?

view this post on Zulip Pat Hickey (Jan 31 2024 at 02:50):

jco is a bytecode alliance project. support for futures/streams/preview 3 is just a glimmer in our eyes, its not a real thing that exists anywhere yet, but when it does it will be rolled out in both wasmtime and jco by the time it is production ready

view this post on Zulip Pat Hickey (Jan 31 2024 at 02:50):

if you want to run things in a js engine, use jco. if you want to run things on windows, linux, or mac, use wasmtime.

view this post on Zulip James Mart (Jan 31 2024 at 03:01):

Yeah was just using futures/streams as a proxy for "when new features come out" (although I am specifically looking forward to async support).

Ok, for some reason I was thinking transpiling with jco would limit me in some way with what wasm features I could use. I'll look more into jco.

view this post on Zulip Alex Crichton (Jan 31 2024 at 03:05):

Ah yes no it's intended that jco is at feature parity with wasmtime and any difference is just a temporary resourcing thing. The "official run in the browser" recommendation is definitely jco


Last updated: Dec 23 2024 at 13:07 UTC