Dead-code elimination and size attribution for WebAssembly modules produced by MoonBit.
$ moon run cmd -- build/cmd.wasm
size 39.6 KiB (40603 bytes)
sections 13
id=1 128 B 0% type
id=2 740 B 1% import
id=3 163 B 0% function
id=7 20 B 0% export
id=10 13.4 KiB 33% code
id=11 1.2 KiB 3% data
id=0 23.7 KiB 59% custom (names/debug)
id=0 69 B 0% custom
functions imported=17 defined=161 total=178
reachable 178
unreachable 0
$ moon run cmd -- build/cmd.wasm --strip
before 39.6 KiB (40603 bytes)
after 15.8 KiB (16227 bytes)
saved 23.8 KiB (60%)# 体积诊断
moon run cmd -- path/to/module.wasm
# 删除自定义段(名字/调试信息),输出到新文件
moon run cmd -- path/to/module.wasm --strip
moon run cmd -- path/to/module.wasm --strip --out slim.wasm
# 定位指令扫描失败的位置(开发用)
moon run cmd -- path/to/module.wasm --debugmoon check --deny-warn
moon test --deny-warn # 5 个单元测试:LEB128 往返、段遍历、magic 校验、裁剪保真
moon build --target wasm # 用本仓库自身产物做端到端样本Install
Download zipDead-code elimination and size attribution for WebAssembly modules produced by MoonBit.