Crates.io | cargo-dao |
lib.rs | cargo-dao |
version | 0.2.0 |
source | src |
created_at | 2021-01-27 00:23:01.236997 |
updated_at | 2021-01-27 06:06:31.628061 |
description | Crate slicing |
homepage | https://github.com/EthanYidong/dao |
repository | https://github.com/EthanYidong/dao |
max_upload_size | |
id | 347092 |
size | 69,922 |
if [] == ![] { console.log("javascript sucks") }
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.
Cargo.toml
files, and need to specify dependencies for each onecargo-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.
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!