Repository navigation
fix(kit): add vite plugins at top level instead of wrapping them - #36037
Conversation
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/kit/test/build.test.ts (1)
177-203: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd a timeout guard or keep the promise deterministic.
The test awaits a promise that only settles when the middleware calls
res.endor whennextruns. IfcreateServerregisters a middleware that returns early (for example a redirect that callswriteHeadthenendwith no body), the assertion onbodybecomes brittle. The current mock returnsundefinedfromwriteHead, so a redirecting middleware would resolve the promise with an unexpected value. Consider asserting onmountedand the middleware output separately, or useserver.middlewares.handlewith a realhttp.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
📒 Files selected for processing (2)
packages/kit/src/build.tspackages/kit/test/build.test.ts
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
36c7200 to
370aaee
Compare

🔗 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
devtoolsproperty in vite plugin was being stripped which I noted when creating nuxt/devtools#1063