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.wasmmoon run cmd -- new.wasm --diff old.wasmold 39.6 KiB (40603 bytes)
new 135.1 KiB (138401 bytes)
delta +97798 bytes
functions old=161 new=311 added=161 removed=11
largest changes:
+6846 B ____moonbit__main (586 -> 7432)
+4635 B zhangbowen20068wasmslim3src4wasm10scan__body (0 -> 4635)
+2521 B zhangbowen20068wasmslim3src8analysis14element__roots (0 -> 2521)
+1890 B zhangbowen20068wasmslim3src8analysis7analyze (0 -> 1890)moon run cmd -- app.wasm --top 10631 B _M0FPB20int__to__string__dec
586 B _M0FP017____moonbit__main
480 B moonbit.utf8.encode_from_utf16
360 B _M0FP414zhangbowen20068wasmslim3src4wasm9read__u32| 规则 | 级别 | 触发条件 |
|---|---|---|
| debug-build | error | custom 段占比 ≥ 20%(实测 debug 为 57–60%,release 为 0%) |
| over-budget | error | 文件大小超过 --budget |
| dead-code | warn | 存在不可达函数(记录数量与函数体字节) |
| ok | info | 没有阻塞问题 |
moon check
moon test # 24 个单元测试
moon build --target wasmInstall
Download zipDead-code elimination and size attribution for WebAssembly modules produced by MoonBit.