Modules and capabilities·/docs/reservoir-and-bundle-size
Bundle size and WebAssembly downloads
Lakeport apps declare Lean packages in lakefile.toml just like any project using Lake and Reservoir (Lean's package registry):
toml
[[require]]
name = "lakeport-primitives"
path = "../packages/lakeport-primitives"
Zero-byte proof erasure
Lean erases every term in Prop before code generation regardless of which .lean or .lp file it lives in, and Lakeport excludes proof-only modules from C and WebAssembly linking automatically. Adding invariants to your app improves compile-time assurance at zero runtime binary cost.
Executable definitions, runtime helpers, and linked native libraries do affect binary size. Use lakeport check --reachability-json to inspect reachable declarations across modules and dependencies.
Size analysis with lakeport size
lakeport size (packages/lakeport-cli/src/LakeportCli/SizeReport.lean) parses built artifacts directly in Lean to break down where bytes go:
sh
lakeport size . --target web
•
WebAssembly: Parses Wasm sections, function body sizes, export/table/elem counts, subsystem attribution, and measures raw, gzip -9, and brotli -11 wire sizes.
•
Native binaries: Inspects Linux ELF, Android APK, macOS Mach-O, and iOS Mach-O artifacts against per-target size budgets.
Fast builds, release profiles & progressive hydration
•
Prebuilt runtime closures: lakeport setup caches prebuilt Wasm and native runtime closures (WasmCache.lean / NativeOpt.lean) so cold builds skip compiling Emscripten/C runtimes from scratch.
•
Dev vs. release profiles: lakeport dev optimizes for fast incremental rebuilds; lakeport build <target> --release enables -Oz, LTO, dead-code section GC, Binaryen wasm-opt, and symbol stripping.
•
Progressive hydration (WasmSplit.lean): Web SSG builds emit dist/web/hydration-manifest.json with per-route hydration strategies (eager, visible, interaction, idle, static-only) and Lean module dependency graphs to minimize initial page load cost.