Stream: wasmtime

Topic: Wasmtime inside the browser?


view this post on Zulip Stuart Lynn (Nov 21 2023 at 10:40):

Hey folks. Hope this is the right place to ask this. Let me know if there is a better venue if not.

I am writing a program in Rust which has a WASM based plugin system. I am trying to figure out if wasmtime or wasmer is the best way to go in terms of a runtime.

One of the core requirements of this Rust application is that it needs to run both natively and in the browser (with the application itself being compiled to WASM).

In the wasmer crate, they have a JS feature which allows you to do this by using the execution javascript environments own WASM compiler instread of cranelift etc ( https://docs.rs/wasmer/latest/wasmer/#overview-of-the-features).

Run Wasmer in a JavaScript environment — With the js Cargo feature, it is possible to compile a Rust program using Wasmer to WebAssembly. In this context, the resulting WebAssembly module will expect to run in a JavaScript environment, like a browser, Node.js, Deno and so on. In this specific scenario, there is no engines or compilers available, it’s the one available in the JavaScript environment that will be used.

I was wondering if wasmtime had a similar feature / ability? I think I would much rather use wasmtime but this would be a deal-breaker if not possible

view this post on Zulip Till Schneidereit (Nov 21 2023 at 11:42):

I would recommend looking into using the WebAssembly Component Model instead of targeting a specific runtime. That way you get the ability to use the results in any runtime implementing the component model, instead of being at the mercy of a specific runtime's trajectory.

Right now, there are pretty solid implementations in wasmtime and JS (via JCO), but at least WAMR and WasmEdge are working on implementations as well

JavaScript tooling for working with WebAssembly Components - GitHub - bytecodealliance/jco: JavaScript tooling for working with WebAssembly Components

Last updated: Nov 22 2024 at 16:03 UTC