Please, help with understanding of the cargo feature crate-type.
I am developing a library that should be available for both TS (via WASM) and Rust.
Can I set this flag conditionally?
[lib]
crate-type = ["cdylib", "rlib"]
So that it's only making a dynamic library when compiled into WASM and into Rust when specified as a dependency in another projects Cargo.toml.
And what if it's a dependency in another crate? Do I specify it in the Cargo.toml there? Or do I keep it without that and only specify it when compiling into WASM?
I'm not sure what dependency you mean.
By default pure Rust dependencies will be compiled as a "lib" and rustc knows how to stitch everything together.
Only the final artifact would be a "cdylib" if that's what you need to produce.
It's also fine to simply have both in the crate-type option as you show and thus always produce both.
The new --crate-type option however would let you control to only built the "cdylib"