Dead-code elimination and size attribution for WebAssembly modules produced by MoonBit.
moon run cmd -- build/app.wasm --checkfile build/app.wasm
size 39.6 KiB (40603 bytes)
profile debug (custom sections 60%)
dead code 0 function(s), 0 body bytes
budget not set
error debug-build looks like a debug build: custom sections are 60% of the file (24370 bytes). Ship a --release build, or strip the module.
verdict FAILprofile release (custom sections 0%)
info ok no blocking issue found.
verdict PASS| 构建 | 大小 | custom 段 | 能否上线 |
|---|---|---|---|
| debug (wasm) | 40603 B | 55.0 KiB (57%) | 不该 |
| release (wasm) | 31706 B | 110 B (0%) | 可以 |
| release (wasm-gc) | 28220 B | 110 B (0%) | 可以 |
# 门禁:debug 构建或超预算时退出码为 1
moon run cmd -- app.wasm --check
moon run cmd -- app.wasm --check --budget 32768
# 体积归因:这些字节花在哪
moon run cmd -- app.wasm
# 需要时裁掉调试信息(debug 产物可减 60%)
moon run cmd -- app.wasm --strip --out slim.wasm| 规则 | 级别 | 触发条件 |
|---|---|---|
| debug-build | error | custom 段占比 ≥ 20%(实测 debug 为 57–60%,release 为 0%) |
| over-budget | error | 文件大小超过 --budget |
| dead-code | warn | 存在不可达函数(记录数量与函数体字节) |
| ok | info | 没有阻塞问题 |
moon check
moon test # 14 个单元测试
moon build --target wasmInstall
Download zipDead-code elimination and size attribution for WebAssembly modules produced by MoonBit.