Hi all, new here, excited to be in the community.
I have a Rust lib crate which is sometimes used as a wasm component (run via wasmtime) and sometimes used as a regular Rust crate dependency when compiling for x86. Some of the exported types in this Rust lib are composed of types imported from bindings generated from a .wit
file.
I would like to use this same Rust crate in a third scenario, a web app (leptos). I've tried a couple things to make this happen, and I have a couple more ideas, but I was wondering if anyone had any insight for this setup?
I would personally suggest splitting your project into multiple crates:
jco
, so you don't need the last option most likely unless you want really tight integration with the DOM and all thatwasm-bindgen
@fitzgen (he/him) thanks for the reply. This is similar to what I was thinking I would have to do, it will just take a little work.
yeah it is usually easier when you design things that way from the start, but that also means that switching now is better than putting it off because it only gets harder as you add API surface and features
If you want to load and run a wit component on the web in Rust, you can use wasm-bridge or wasm_component_layer.
Although since you have your crate as a normal Rust crate as well, you would probably be better off just including that as a normal dependency instead of loading it as a wit component.
@Karel Hrkal (kajacx) wasm-bridge
is really cool. I'll likely need to use it soon. Nice documentation!
Last updated: Nov 22 2024 at 16:03 UTC