Skip to content

build: bundle runtime entries and drop traced node_modules - #4701

Merged
pi0 merged 2 commits into
mainfrom
build/bundle-runtime
Oct 3, 2026
Merged

pi0 merged 2 commits into
mainfrom
build/bundle-runtime

Conversation

@pi0x

@pi0x pi0x commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Bundles every runtime file (src/runtime/** and src/presets/*/runtime/**) as entries of one rolldown build, so dependencies are inlined into chunks shared across runtime entries (dist/runtime/_libs, dist/runtime/_chunks) instead of traced into dist/node_modules.

  • Each runtime file is still emitted at its previous path (build code references them via runtimeDir / presetsDir).
  • Runtime is a separate bundle from the builder: rolldown lib groups capture dependencies recursively, so a combined bundle leaked build-time code (c12, node:fs) into runtime chunks.
  • #… imports keep side effects (obuild's no-external was dropping import "#nitro/virtual/polyfills"), and the polyfills import is hoisted back to the top of chunks since rolldown places chunk and external imports above it.
  • Generated renderer template imports renderToResponse via #nitro/runtime/rendu (previously resolved from traced rendu).
  • Runtime uses console instead of consola.
  • rou3 moved to devDependencies (build-time only, now bundled).

hookable is bundled too (moved to devDependencies). Its classes have private members, so inlined .d.ts copies would not be assignable to each other; public Nitro.hooks / NitroApp.hooks now use handrolled structural Hookable / HookableCore interfaces (src/types/_hookable.ts). Generated app code imports HookableCore via #nitro/runtime/hookable.

Inlined runtime libs now live under nitro's dist, so in user builds they land in _chunks/ instead of _libs/<pkg>.mjs.

Size: packed tarball 660.7 KB → 603.2 KB (−8.7%), unpacked 2424 KB → 2186 KB (−9.8%), 415 → 407 files.

🤖 Generated with AI assistant

Bundle all runtime and preset runtime files as entries of a single rolldown build so dependencies are inlined into shared chunks (`dist/runtime/_libs`) instead of being traced into `dist/node_modules`.

- route generated renderer template `rendu` import through `#nitro/runtime/rendu`
- use `console` instead of `consola` in runtime
- move `rou3` to dev dependencies (build-time only, bundled)
@pi0x
pi0x requested a review from pi0 as a code owner October 3, 2026 12:50
@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nitro.build Ready Ready Preview Oct 3, 2026 12:54pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3ae490ba-d25e-4c13-9504-d62d81e86177
📥 Commits

Reviewing files that changed from the base of the PR and between 291a315 and 9bcfc1d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • build.config.ts
  • package.json
  • src/build/virtual/renderer-template.ts
  • src/presets/_nitro/runtime/nitro-prerenderer.ts
  • src/runtime/internal/error/dev.ts
  • src/runtime/internal/rendu.ts
  • src/runtime/meta.ts
  • src/runtime/virtual/_runtime_warn.ts
 _________________________
< Think twice, code once. >
 -------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4701

commit: c169bc6

Public `Nitro.hooks` and `NitroApp.hooks` use structural `Hookable` / `HookableCore` interfaces so inlined type copies stay assignable (hookable classes have private members).
@pi0
pi0 merged commit 9889074 into main Oct 3, 2026
14 checks passed
@pi0
pi0 deleted the build/bundle-runtime branch October 3, 2026 12:59
pi0x pushed a commit to meta-syntax/nitro that referenced this pull request Oct 13, 2026
Runtime deps are no longer traced since nitrojs#4701, so the dev public assets template imports `mime` via `#nitro/runtime/mime`.

This branch was successfully deployed

1 active deployment
Preview — c169bc66 Deployed Oct 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants