How Thinpack.js Packs tsc into 6.5–9 MiB Instead of 110 MiB
Most single-executable JS packagers treat the runtime as an immutable 100+ MiB blob. Thinpack.js treats the runtime itself as a tree-shakeable Rust workspace.
1. The 100 MiB Problem with Single-File JavaScript
When you bundle a CLI with node --experimental-sea-config or bun build --compile, your application code is only a small fraction of the resulting artifact. Even for @earendil-works/pi-coding-agent (2,377 modules, 16.5 MB of JavaScript), Bun's binary is 115.24 MiB because roughly 102 MiB is fixed runtime overhead, and Node SEA's binary is 157.75 MiB because ~143.5 MiB is fixed Node engine.
For backend microservices, 110 MiB is tolerable. For CLI tools installed via Homebrew, curl installers, or GitHub Releases across macOS, Linux, and Windows, shipping 100+ MiB per target slows down downloads, bloats release archives, and wastes CI bandwidth.
2. Static Analysis with Oxc & Capability Closure
At pack time, thinpack-analyze parses your JavaScript and TypeScript files using Rust's oxc parser instead of guessing with regexes:
- TypeScript stripping without bundling
tsc:.ts,.mts, and.ctsfiles undergo a strip-only pass matching Node without--experimental-transform-types, and type-only imports are erased prior to resolution. - Built-in & global capability detection: Static imports (
node:fs,crypto, conditionalrequire()branches) and unshadowed globals (likefetchorWebSocket) map to entries incapabilities.toml. - Dynamic path & data inference: Safe static patterns like
path.join(__dirname, 'lib/motd'), literal object-property constants,fs.readdir/readFileSyncdata trees, andpkg.bin[name]launchers are traced automatically so real npm CLIs pack without manual boilerplate.
3. Feature-Trimmed Rust Runtime Templates
capabilities.toml is the single source of truth. Running cargo xtask gen emits the module table in thinpack-caps and Cargo feature flags in thinpack-rt. Each Node built-in lives in its own crate under crates/node/* (console, fs, https, buffer, url, sea, test, ffi, and more).
When you run thinpack pack --rebuild --source /path/to/thinpack.js, Cargo links only the capability closure your app needs. A minimal Core QuickJS template with zero built-ins compiles down to 5.20 MiB (2.22 MiB gzip), while full-module QuickJS is 11.61 MiB. Node's own JavaScript standard library glue is brotli-compressed inside thinpack-js (thinpack_js::js!): 2.0 MB of JavaScript adds only 0.43 MB to the template.
Notably, HTTP-only apps do not carry the 16-module undici bundle used by fetch and WebSocket—they carry only the extracted llhttp Wasm parser inside node:http.
4. Virtual Filesystem at /app & Engine Abstraction (v8x)
At runtime, thinpack-vfs mounts your bundled files read-only under /app/** (writes return EROFS), while host paths outside /app pass through to the real OS filesystem so tools like ESLint or Prettier still read project configs in the user's working directory.
Everything runs atop an engine-agnostic embedding layer (thinpack-js/v8x), letting the same packed payload target QuickJS (default, smallest), V8 (fastest throughput), or macOS JavaScriptCore (jsc, zero bundled engine).
5. Verified Size vs Speed Trade-Offs
| Program | Thinpack (MiB) | Bun 1.4.4 (MiB) | Node 26.8.1 SEA | Thinpack cold / warm | SEA startup |
|---|---|---|---|---|---|
| Hello World hello.js |
4.03 (~1.80 gz) | 104.10 | 143.70 | — | Failed |
| tsc (TypeScript 5.9) typescript@5.9.3 |
9.00 (5.65 gz) | 109.63 (50.19 gz) | 149.82 (45.35 gz) | 578 / 347 ms | 77 ms |
| ESLint 10 eslint@10.15.0 |
6.93 (3.60 gz) | 107.15 (49.78 gz) | 147.25 (44.96 gz) | 288 / 186 ms | 64 ms |
| Prettier 3 prettier@3.10.1 |
7.41 (4.14 gz) | 110.04 (50.85 gz) | 143.57 (44.32 gz) | 235 / 155 ms | Failed |
| Terser 5 terser@5.51.2 |
6.06 (2.91 gz) | 105.38 (49.48 gz) | 144.94 (44.57 gz) | 226 / 145 ms | 35 ms |
| js-yaml 5 js-yaml@5.5.0 |
5.80 (2.69 gz) | 104.29 (49.28 gz) | 143.75 (44.37 gz) | 150 / 100 ms | Failed |
| pi-coding-agent @earendil-works/pi-coding-agent@1.5.0 |
12.42 (7.16 gz) | 115.24 (51.30 gz) | 157.75 (46.94 gz) | 983 / 702 ms | Failed |
Notice the honest engineering trade-off: QuickJS achieves 12–25x smaller binaries than Bun and Node SEA, while cold start is 4–8x slower due to QuickJS's interpreter/parser cost. For a linter or compiler that runs for seconds, 288–578 ms is negligible compared to saving 100 MiB per download; for tight sub-50 ms CLI loops, --backend v8 gives you V8's JIT in 45–52 MiB.
Shipping smaller Node.js CLIs? Star thinpack.js on GitHub
thinpack.js is 100% MIT-licensed and actively developed in Rust + JavaScript. If you ship Node.js CLIs and want 4–12 MiB binaries instead of 104–158 MiB runtimes, starring the repository helps other developers discover it and prioritizes new Node compatibility fixtures.