Skip to content

fix(vite): find the entry of a service environment marked as built - #5007

Merged
pi0 merged 1 commit into
mainfrom
fix/vite-built-no-entry
Nov 2, 2026
Merged

pi0 merged 1 commit into
mainfrom
fix/vite-built-no-entry

Conversation

@pi0x

@pi0x pi0x commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #5005

A service environment marked isBuilt before Nitro's buildApp (e.g. ssr output restored from a framework build cache) is skipped, so its generateBundle never runs and Nitro never learns its entry file. #nitro/virtual/vite-services then imports the output folder, which only resolves when the entry is index.{mjs,js}.

  • Service builds now emit a nitro-service.json manifest ({ entry }) next to their output.
  • When a registered service is marked as built, the entry is read from that manifest. Output without one (e.g. from an older Nitro) keeps the previous folder import.

Based on the fix by @onmax (co-authored).

🤖 Generated with AI assistant

@pi0x
pi0x requested a review from pi0 as a code owner November 2, 2026 17:49
@vercel

vercel Bot commented Nov 2, 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 Nov 2, 2026 5:52pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Findings

Actionable comments posted: 2

Caution

Review failed

The pull request is closed.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 94a20d1a-c0df-468e-8e6d-c0d56603509e
Commits

Reviewing files that changed from the base of the PR and between 2b4d4ce and e96fea9.

Files selected for processing: 6
  • src/build/vite/plugin.ts
  • src/build/vite/prod.ts
  • src/build/vite/services.ts
  • test/vite/built-service-fixture/entry-server.ts
  • test/vite/built-service-fixture/vite.config.ts
  • test/vite/built-service.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

Nitro now records service entry filenames in build output and loads them when a Vite environment is already built but has no entry point in ctx._entryPoints. A regression test covers a built service with a hashed entry filename.

Changes: Built service entry resolution

Layer / File(s) Summary
Record service entry filenames
src/build/vite/services.ts, src/build/vite/plugin.ts
Nitro defines a service manifest filename and a helper that reads its entry, falls back to index.mjs, or throws an error. Bundle generation emits the service entry filename in the manifest.
Resolve entries for built environments
src/build/vite/prod.ts, test/vite/built-service-fixture/*, test/vite/built-service.test.ts
When a built environment has a matching service but no entry point, Nitro reads its entry from the output directory. The test builds with a hashed entry filename and checks that the generated server handles a request.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

Suggested labels: vite plugin

  • Autofix · 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

@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: e96fea9

Nitro only learned a service's entry file in that environment's `generateBundle`, so a service marked `isBuilt` before Nitro's `buildApp` imported its output folder, which fails unless the entry is `index.mjs`. Service builds now write a `nitro-service.json` manifest next to their output, read back when the environment is skipped.

Resolves #5005

Co-authored-by: onmax <[email protected]>
@pi0x
pi0x force-pushed the fix/vite-built-no-entry branch from e96fea9 to 5572b24 Compare November 2, 2026 17:52
@pi0
pi0 merged commit 5a9688e into main Nov 2, 2026
14 checks passed
@pi0
pi0 deleted the fix/vite-built-no-entry branch November 2, 2026 17:54

This branch was successfully deployed

1 active deployment
Preview — 5572b248 Deployed Nov 2, 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.

vite: build fails when a service environment marked as built has no index.mjs entry

2 participants