fix(kit): add vite plugins at top level instead of wrapping them by danielroe · Pull Request #36037 · nuxt/nuxt · GitHub
Skip to content

fix(kit): add vite plugins at top level instead of wrapping them - #36037

Merged
danielroe merged 2 commits into
mainfrom
fix/plugin-env-wrapper
Aug 11, 2026
Merged

danielroe merged 2 commits into
mainfrom
fix/plugin-env-wrapper

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

this aims to simplify/refactor the logic for adding vite plugins, given that vite environment api is the default going forward.

resolves an issue with https://github.com/nuxt/devtools whereby the new devtools property in vite plugin was being stripped which I noted when creating nuxt/devtools#1063

@github-actions github-actions Bot added 5.x 🐛 bug Something isn't working as expected labels Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/kit/test/build.test.ts (1)

177-203: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a timeout guard or keep the promise deterministic.

The test awaits a promise that only settles when the middleware calls res.end or when next runs. If createServer registers a middleware that returns early (for example a redirect that calls writeHead then end with no body), the assertion on body becomes brittle. The current mock returns undefined from writeHead, so a redirecting middleware would resolve the promise with an unexpected value. Consider asserting on mounted and the middleware output separately, or use server.middlewares.handle with a real http.ServerResponse.

This is optional. The test passes with the current plugin set.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/kit/test/build.test.ts` around lines 177 - 203, Make the
middleware-response assertion in the real Vite server test deterministic by
avoiding reliance on the mock response’s incomplete redirect behavior. Update
the promise/mock around server.middlewares (or use a real ServerResponse) so
redirects and early middleware exits cannot resolve body with an unexpected
value, while preserving the existing mounted and '{"ok":true}' assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/kit/test/build.test.ts`:
- Around line 177-203: Make the middleware-response assertion in the real Vite
server test deterministic by avoiding reliance on the mock response’s incomplete
redirect behavior. Update the promise/mock around server.middlewares (or use a
real ServerResponse) so redirects and early middleware exits cannot resolve body
with an unexpected value, while preserving the existing mounted and
'{"ok":true}' assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 50e2e0d4-9da2-46c1-8f93-54c4bf541c92

📥 Commits

Reviewing files that changed from the base of the PR and between 409c27f and 36c7200.

📒 Files selected for processing (2)
  • packages/kit/src/build.ts
  • packages/kit/test/build.test.ts

@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@36037

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@36037

nuxt

npm i https://pkg.pr.new/nuxt@36037

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@36037

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@36037

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@36037

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@36037

commit: 370aaee

@codspeed

codspeed Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

@danielroe
danielroe force-pushed the fix/plugin-env-wrapper branch from 36c7200 to 370aaee Compare August 11, 2026 20:02
@danielroe
danielroe added this pull request to the merge queue Aug 11, 2026
Merged via the queue into main with commit b3becb6 Aug 11, 2026
34 checks passed
@danielroe
danielroe deleted the fix/plugin-env-wrapper branch August 11, 2026 21:51
@github-actions github-actions Bot mentioned this pull request Aug 11, 2026
2 of 5 tasks
@github-actions github-actions Bot mentioned this pull request Aug 12, 2026
This was referenced Aug 25, 2026
@github-actions github-actions Bot mentioned this pull request Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.x 🐛 bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant