Skip to content

fix(vite): pass aliases as ordered entries so specific keys win - #4537

Merged
pi0 merged 2 commits into
mainfrom
fix/vite-alias
Aug 20, 2026
Merged

fix(vite): pass aliases as ordered entries so specific keys win#4537
pi0 merged 2 commits into
mainfrom
fix/vite-alias

Conversation

@danielroe

@danielroe danielroe commented Aug 18, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

spotted this issue in nuxt - although nitro correctly orders aliases, vite ignores the order when it merges with other config that's passed to it.

this is a hotfix - we can also look to try to resolve this in vite itself.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe
danielroe requested a review from pi0 as a code owner August 18, 2026 21:32
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview Aug 20, 2026 6:25pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d5bd59d-694e-4fd6-ad65-db8fe7949063

📥 Commits

Reviewing files that changed from the base of the PR and between 3b805a5 and 90dc450.

📒 Files selected for processing (1)
  • tsconfig.json

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


📝 Walkthrough

Walkthrough

The Nitro Vite plugin converts bundler aliases into ordered Vite alias entries. A fixture and integration test verify alias resolution for Rolldown, Rollup, and Vite builders.

Changes

Vite alias precedence

Layer / File(s) Summary
Convert bundler aliases for Vite
src/build/vite/plugin.ts
The plugin maps bundler aliases into ordered { find, replacement } entries before passing them to Vite.
Define alias resolution fixture
test/vite/alias-precedence-fixture/..., tsconfig.json
The fixture defines overlapping Nitro and Vite aliases, runtime exports, and a server response that exposes the resolved values.
Exercise alias precedence across builders
test/vite/alias-precedence.test.ts
The integration test builds the fixture with Rolldown, Rollup, and Vite, then verifies the generated server response.

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

Merge Risk: ⚪ Minimal · up to 90dc4

This localized change makes specific Vite aliases take precedence as intended and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the conventional commit format and clearly describes the Vite alias precedence fix.
Description check ✅ Passed The description explains the Vite alias handling bug, its impact, and the intended hotfix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/vite-alias

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 Aug 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 90dc450

@pi0
pi0 merged commit 0ddcf3c into main Aug 20, 2026
13 checks passed
@pi0
pi0 deleted the fix/vite-alias branch August 20, 2026 18:28
@pi0 pi0 mentioned this pull request Aug 21, 2026
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