How to create common that target both wasm and lib(native)?

I am new to rust. I was thinking of creating a rust library using wasm-bindgen, so that it can be compiled to wasm using wasm-pack and with cargo build to native lib(.rlib). But, the problem is wasmbinding get include to native lib. Is there a way to ignore wasm-bindings when targeting for desktop?. So, that i can create a common library code base.

You can hide wasm-only things with #[cfg(target_arch = "wasm32")].

You can have wasm-only attributes with #[cfg_attr(target_arch = "wasm32", <insert attribute here>)]

You can have wasm-only dependencies in Cargo.toml with [target.'cfg(target_arch = "wasm32")'.dependencies]

And replace target_arch = "wasm32" with not(target_arch = "wasm32") for non-wasm versions.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.