3 unstable releases
0.2.0 | Jan 27, 2021 |
---|---|
0.1.1 | Jan 27, 2021 |
0.1.0 | Jan 27, 2021 |
#677 in Cargo plugins
20KB
121 lines
cargo-刀
if [] == ![] { console.log("javascript sucks") }
- The only replacement for JavaScript is WASM
- Rust compiles to WASM
- Rust is great
- Replace Javascript with rust
What is this?
Currently, the only way to have multiple library outputs from Rust is to use multiple crates. This has a few downsides, especially when you want multiple WASM files.
- You need multiple
Cargo.toml
files, and need to specify dependencies for each one - If you have shared dependencies, you need to specify a separate crate for that as well
cargo-dao
is a wrapper for wasm-pack
(a very great tool) that allows you to compile multiple wasm binaries with only one crate. All you need is to add #[cfg(dao = "output_name")]
to each part of the code you need for each output binary (quite like features). cargo-dao
will automagically detect all instences of #[cfg]
, and compile a separate binary for each one.
Example
In the wasm-pack-example
directory, run cargo dao --target web --out-dir web/pkg
, and start a web server in web/
. Check the console output on your browser!
Dependencies
~39–54MB
~1M SLoC