Skip to content

fix(vite): allow providing the vite package path - #4637

Merged
pi0 merged 2 commits into
mainfrom
fix/vite-path
Sep 17, 2026
Merged

pi0 merged 2 commits into
mainfrom
fix/vite-path

Conversation

@pi0x

@pi0x pi0x commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Resolves #4636

Nitro resolves vite from the project root. When a framework runs Vite programmatically in a monorepo where another vite version is hoisted next to the app (Vite 7 at the root, Vite 8 in the framework), the dev worker ends up with the wrong vite/module-runner and every request fails with Missing field moduleType.

This adds a vite.path option to point Nitro at the vite package that is actually running:

nitro({ vite: { path: import.meta.resolve("vite") } })

Nitro also warns in dev when the vite it resolved differs from the running one, and points at this option.

🤖 Generated with AI assistant

Frameworks running Vite programmatically can pass their own `vite` with
the `vite.path` option, so the dev module runner matches the running
instance (in a monorepo, another version can be hoisted next to the app).

resolves #4636
@pi0x
pi0x requested a review from pi0 as a code owner September 17, 2026 17:19
@vercel

vercel Bot commented Sep 17, 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 Sep 17, 2026 5:24pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ce0b67ad-701b-4292-b133-8edb09b93b0d

📥 Commits

Reviewing files that changed from the base of the PR and between e705d1a and 7330abe.

📒 Files selected for processing (12)
  • docs/1.docs/61.vite.md
  • docs/3.config/0.index.md
  • src/build/vite/_dev-worker.ts
  • src/build/vite/_import.ts
  • src/build/vite/build.ts
  • src/build/vite/dev.ts
  • src/build/vite/env.ts
  • src/build/vite/plugin.ts
  • src/config/resolvers/builder.ts
  • src/types/config.ts
  • test/vite/vite-path-fixture/routes/index.ts
  • test/vite/vite-path.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Nitro adds vite.path configuration for selecting a Vite package from a filesystem path or file:// URL. Build and development flows use the selected package, serve mode reports version differences, and integration tests verify package selection.

Changes

Vite package resolution

Layer / File(s) Summary
Configuration and package resolution
src/types/config.ts, src/build/vite/_import.ts, src/config/resolvers/builder.ts, docs/1.docs/61.vite.md, docs/3.config/0.index.md
Adds NitroOptions.vite.path, resolves Vite exports from configured paths or URLs, updates builder checks, and documents the option.
Build and development integration
src/build/vite/build.ts, src/build/vite/_dev-worker.ts, src/build/vite/dev.ts, src/build/vite/env.ts
Propagates derived Vite import options through build and development environments, including module-runner resolution and cache keys.
Version diagnostics and integration coverage
src/build/vite/plugin.ts, test/vite/vite-path-fixture/routes/index.ts, test/vite/vite-path.test.ts
Checks resolved and running Vite versions during serve and verifies configured package selection with an integration test.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 7330a

No confirmed issue remains; the change is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #4636 requires Nitro to add vite back as an optional peer dependency because Nitro imports Vite directly. The reviewed changes add vite.path resolution and an integration test, but the whole… Add vite to Nitro's optional peerDependencies with the supported version range, and mark it optional in peerDependenciesMeta. Keep the vite.path behavior only if it remains part of the intended solution.
Docstring Coverage ⚠️ Warning Docstring coverage is 58.82% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 10 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits format with the fix type, vite scope, and a clear summary of the change.
Description check ✅ Passed The description directly explains the vite.path option, the monorepo resolution issue, and the development warning added by the changeset.
Out of Scope Changes check ✅ Passed The vite.path option, explicit Vite resolution, development version warning, documentation, and integration test all address the version-mismatch and monorepo resolution problem described by issue #…
Full details: Linked Issues check

Explanation

Issue #4636 requires Nitro to add vite back as an optional peer dependency because Nitro imports Vite directly. The reviewed changes add vite.path resolution and an integration test, but the whole-PR diff contains no package.json or peer-dependency change. The required optional peer dependency is therefore not implemented.

Full details: Docstring Coverage

Explanation

Docstring coverage is 58.82% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 10 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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 Sep 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 7330abe

@pi0
pi0 merged commit e2e14e7 into main Sep 17, 2026
14 of 15 checks passed
@pi0
pi0 deleted the fix/vite-path branch September 17, 2026 17:30
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.

add back vite optional peer dependency

2 participants