Assign crate-type based on compiled target


I aware that we can use different dependencies based on the compiled target, like:


wasm-bindgen = "0.2.29"

jni = { version = "0.5", default-features = false }

Can we define crate-type based on the target type as well, I tried the below but it failed;

name = "greetings"
crate-type = ["rlib"]

crate-type = ["cdylib"]

crate-type = ["dylib"]

crate-type = ["cdylib"]

crate-type = ["staticlib"]

Once I tried compiling for was32 for example, I got the below error:

Hasans-Air:utils2 h_ajsf$ wasm-pack build

  **[1/9]** 🦀 Checking `rustc` version...

  **[2/9]** 🔧 Checking crate configuration...

crate-type must be cdylib to compile to wasm32-unknown-unknown. Add the following to your Cargo.toml file:


crate-type = ["cdylib", "rlib"]

You could use features to do this, but you will have to manually enable features to turn on certain libraries