Hello!
I have a bit of a weird idea.
Basically, I'm working on a game written in Rust that compiles to web and for desktop, and I kinda want to use wasmtime for scripting.
However, i would want to make it so that when i compile my game for the web, instead of the wasm going through wasmtime, it just gets run by the browser itself along with the surrounding wasm wrapper.
is this even possible?
The main reason I would want to do this is to be able to hot reload my game logic while developing
Hey @Srayan Jana so I think what you'd want here is something that can transpile your modules for use in the browser and make available the transpiled module on the web (so you can import) them.
If you're running a dev server locally this is actually really analogous to bundling for the web, but basically what you want to do is attempt to bundle and serve the transpiled sources of the component when someone requests that component (or some URL that corresponds to the component in question).
Easy way is probably to run jco transpile as a subprocess on the server side, better way would be to build in https://crates.io/crates/js-component-bindgen, which Jco depends on to do it's transpilation via jco-transpile (see: https://github.com/bytecodealliance/jco/blob/main/packages/jco-transpile/src/transpile.ts)
If you're bundling your web app, then you can write a small rolldown plugin that does this at build time, but obviously if you want to do it on the fly in a dev context (or even a live context) then you kind of need something to do the translation between the component and the translated ES module you want to actually load.
If eval is an option in the browser environment, then there are more options -- you could run jco-transpile itself in a WebWorker for example and and then eval the module source code you get out... But you could see how that's a bit more "exciting" than simply preparing the module out of band via a web server you control
this makes sense,
it just sucks that because I'm commited to doing both web and native, I'm having to re implement things twice lol.
Ah well, this is the price I pay, and thankfully this does seem like exactly what I want
Yeah let us know how this goes for you!
BTW
https://github.com/rioam2/rollup-plugin-jco/blob/main/README.md
:)
I'm not sure I'd throw in the towel quite yet. I'm still not quite clear what exactly you're trying to do. "Compile to web and desktop" gotcha there (although I've struggled with what to call using webassembly outside the browser. Stand alone? Native? Not in a browser, like on a server type thing? It would be nice if there was a good name for that)
"use wasmtime for scripting" not quite sure what you're looking for there and that has me a little confused with the "it just gets run by the browser itself along with the surrounding wasm wrapper". I get the second but not quite sure what you were looking for with the first.
Last updated: Jul 29 2026 at 05:03 UTC