chore: wasm-snip init

This commit is contained in:
Zixuan Chen 2023-11-29 15:07:39 +08:00
parent ced4f4d5a5
commit e342dfc98a
No known key found for this signature in database
3 changed files with 8 additions and 3 deletions

View file

@ -74,8 +74,9 @@ https://github.com/loro-dev/loro/assets/18425020/ec2d20a3-3d8c-4483-a601-b200243
5. **Rust Target**: Add with `rustup target add wasm32-unknown-unknown`.
6. **wasm-bindgen-cli**: Install version 0.2.86 via `cargo install wasm-bindgen-cli --version 0.2.86`.
6. **wasm-opt**: Install using `cargo install wasm-opt --locked`.
7. **cargo-nextest**: Install using `cargo install cargo-nextest --locked`.
8. **cargo-fuzz**: Run `cargo install cargo-fuzz`.
7. **wasm-snip**: Install using `cargo install wasm-snip`.
8. **cargo-nextest**: Install using `cargo install cargo-nextest --locked`.
9. **cargo-fuzz**: Run `cargo install cargo-fuzz`.
### Test

View file

@ -1,5 +1,5 @@
[profile.release]
lto = true
opt-level = "s"
debug = false
debug = true
codegen-units = 1

View file

@ -37,6 +37,10 @@ async function build() {
if (profile !== "dev") {
await Promise.all(
TARGETS.map(async (target) => {
// --snip-rust-panicking-code --snip-rust-fmt-code
const snip = `wasm-snip ./${target}/loro_wasm_bg.wasm -o ./${target}/loro_wasm_bg.wasm`;
console.log(">", snip);
await Deno.run({ cmd: snip.split(" "), cwd: LoroWasmDir }).status();
const cmd = `wasm-opt -Os ./${target}/loro_wasm_bg.wasm -o ./${target}/loro_wasm_bg.wasm`;
console.log(">", cmd);
await Deno.run({ cmd: cmd.split(" "), cwd: LoroWasmDir }).status();