Hello everyone, I am trying to contribute to Leptos to make it capable of compiling the server side down to a WebAssembly Component.
I had sparkles :sparkles: of happiness when I saw the commit promoting wasm32-wasip2 target to Tier 2 landing in 1.81, and then learned about the hard truth :tear:
So If I want to do that, for now, I need to target wasm32-wasip1 (so the toolchain comes with wasm-ld, IIUC) and then do the "componentisation".
My question may be a really stupid one since I am not familiar with cargo plugin systems, but can two cargo plugin integrates?
Basically, cargo leptos allows users to have a single codebase but compile two artifacts (one for the client side, one for the server), it seems to do so by spawning the cargo binary: https://github.com/leptos-rs/cargo-leptos/blob/main/src/compile/server.rs#L29
I feel like I have two choice:
cargo component does in cargo leptos,cargo leptos calls cargo component (i.e. a plugin spawning a cargo plugin)The second approach seems the simpler but I don't know if it's "Idiomatic", do you have any recommendations? :pray:
raskyld said:
I feel like I have two choice:
- Reimplement what
cargo componentdoes incargo leptos,- Make
cargo leptoscallscargo component(i.e. a plugin spawning a cargo plugin)
The second is probably what I would start with. The commands in cargo are fairly stable, and since cargo component largely mirrors the API it probably also stay reasonably stable.
If cargo-component is installed and available from your path, then yeah you should just be able to call it from a command.
Though I guess: another option could be to use the wasm32-wasip2 target on beta by doing something like this
Rust 1.82 should be released in ~3 weeks, so depending on your needs that might potentially be the smoothest transition?
Though I don't know whether you just want to compile for WASI 0.2, or whether you also need any other functionality from cargo-component. Using the beta toolchain directly with Cargo probably works best if you don't need any of the other cargo-component functionality.
Thanks a lot for the answer!
I went with using cargo-component with the requirements that it should be in the users' PATH for now (it's just a PoC anyway).
Last updated: Dec 06 2025 at 06:05 UTC