nitro icon indicating copy to clipboard operation
nitro copied to clipboard

build: bundle dependencies to reduce install size

Open pi0 opened this issue 9 months ago • 1 comments

(experimental draft)

This is an experimental attempt in order to reduce the total install size of nitro.

What is bundled: (check build.config)

What is not bundled:

  • Runtime dependencies
  • Native dependencies
  • Incompatible to bundle
  • Deps used by presets
  • Common deps

Results:

  • Before: 74MB / 5,415 files
  • After: 48MB / 3,300 files

bundled dist+deps: 4.6MB

Breakdown of remaining external deps: (linux/pnpm -- total is 49MB ignoring 1MB of overlaps for simplicity)

  • utils: 2.6MB (croner, globby, klona, unplugin)
  • error: 2.1MB (youch youch/core source-map)
  • rollup (without plugins): 7.7MB
  • esbuild: 10MB
  • @vercel/nft: 10MB
  • unjs: 12MB (confbox consola compatx cookie-es crossws db0 defu destr h3 hookable jiti node-mock-http mlly pathe pkg-types ofetch ohash radix3 scule std-env ufo uncrypto unctx unenv unstorage)

pi0 avatar Mar 24 '25 22:03 pi0

Deploying nitrojs with  Cloudflare Pages  Cloudflare Pages

Latest commit: ee92e2d
Status: ✅  Deploy successful!
Preview URL: https://51bbb964.nitrojs.pages.dev
Branch Preview URL: https://build-inline-deps.nitrojs.pages.dev

View logs

reworking with progressive attempts starting with #3619

pi0 avatar Oct 06 '25 00:10 pi0