Closed GISerliang closed 1 week ago
I'm confused by the question, to be honest; as far as I know it will already compile the lib crate to wasm32. Maybe you could provide some example code and what the error is?
I'm confused by the question, to be honest; as far as I know it will already compile the lib crate to wasm32. Maybe you could provide some example code and what the error is?
Right, so placing it in the app.rs
that is used by both the browser/client-side (compiling from lib.rs) and from the server-side (compiling from main.rs) means that it is not available when compiling the server, hence the error.
You should consider feature-gating the import with something like #[cfg(feature = "hydrate")]
Right, so placing it in the
app.rs
that is used by both the browser/client-side (compiling from lib.rs) and from the server-side (compiling from main.rs) means that it is not available when compiling the server, hence the error.You should consider feature-gating the import with something like
#[cfg(feature = "hydrate")]
Thanks. I wiil try this method. But I also want to know could I only compile the browser/client-side?
Thanks. I wiil try this method. But I also want to know could I only compile the browser/client-side?
Do you mean if you don't want a server at all? Yes, but then the cargo-leptos setup you're using is not the best, as it's specifically designed to build the server and the browser halves at once. If you're not actually using the server, then just use Trunk or wasm-pack and build a client-side app.
Do you mean if you don't want a server at all? Yes, but then the cargo-leptos setup you're using is not the best, as it's specifically designed to build the server and the browser halves at once. If you're not actually using the server, then just use Trunk or wasm-pack and build a client-side app.
I understand you means. Thanks.
I want use
leptos_dom::Mountable
, but this trait is available for wasm32 arch like below picture.I also set toolchain in
rust-toolchain.toml
liketargets = ["wasm32-unknown-unknown"]
, but I runcargo leptos watch
command got an error.I want to know how to set the frontend library compile into wasm32?