Skip to content

Conversation

@danielroe
Copy link
Member

🔗 Linked issue

📚 Description

with #33262, the types for vite are changing - and.I think it makes sense for $client, $server and viteNode types to be defined by the builder rather than by the Nuxt schema more generally

might think of a way to deprecate the global types for these (shared through schema)

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link

coderabbitai bot commented Oct 8, 2025

Walkthrough

The changes introduce resolveModulePath usage in Nuxt core to resolve the vite builder path and adjust nodeReferences based on the builder option. The schema package expands public exports, adds a new ViteOptions type, and updates ConfigSchema to use ViteOptions instead of a composite ViteConfig, also adding a viteEnvironmentApi boolean. The vite package removes a ViteBuildContext re-export and augments nuxt/schema by extending ViteOptions with optional $client, $server, and viteNode fields. Imports and types are realigned accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Heterogeneous but mostly type-surface changes across multiple packages
  • Limited runtime logic change in nuxt core with a small conditional and path resolution
  • Significant public typing refactor and module augmentation requiring careful API surface review
  • No complex algorithms; primary effort is consistency and compatibility verification across packages

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly summarises the core change by indicating a refactor across Nuxt, Vite and Webpack to allow builders to augment types and directly reflects the primary objective of the pull request without extraneous detail.
Description Check ✅ Passed The pull request description clearly explains the motivation for shifting $client, $server and viteNode type definitions from the Nuxt schema into individual builders in light of recent Vite type changes and remains directly related to the implemented modifications.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/vite-augments

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ef632b and 33f4217.

⛔ Files ignored due to path filters (2)
  • packages/vite/package.json is excluded by !**/package.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (5)
  • packages/nuxt/src/core/nuxt.ts (3 hunks)
  • packages/schema/src/index.ts (1 hunks)
  • packages/schema/src/types/config.ts (1 hunks)
  • packages/schema/src/types/schema.ts (3 hunks)
  • packages/vite/src/index.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • packages/schema/src/types/config.ts
  • packages/vite/src/index.ts
  • packages/schema/src/index.ts
  • packages/nuxt/src/core/nuxt.ts
  • packages/schema/src/types/schema.ts
🧠 Learnings (1)
📚 Learning: 2024-11-05T15:22:54.759Z
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.

Applied to files:

  • packages/nuxt/src/core/nuxt.ts
🧬 Code graph analysis (3)
packages/schema/src/types/config.ts (1)
packages/schema/src/index.ts (2)
  • ViteOptions (4-4)
  • ViteConfig (4-4)
packages/vite/src/index.ts (2)
packages/schema/src/index.ts (2)
  • ViteOptions (4-4)
  • ViteConfig (4-4)
packages/schema/src/types/config.ts (2)
  • ViteOptions (130-130)
  • ViteConfig (96-127)
packages/schema/src/types/schema.ts (2)
packages/schema/src/index.ts (1)
  • ViteOptions (4-4)
packages/schema/src/types/config.ts (1)
  • ViteOptions (130-130)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (7)
packages/nuxt/src/core/nuxt.ts (2)

25-25: LGTM!

The choice of exsolve for module path resolution is appropriate for this use case.


255-257: Verify custom builder package existence before adding type reference.

The custom builder string is pushed directly to nodeReferences without validation or path resolution, unlike the @nuxt/vite-builder handling above. If the builder package doesn't exist or isn't properly installed, TypeScript will fail to resolve these types.

Consider adding similar resolution logic for consistency and early error detection:

     opts.nodeReferences.push({ types: relative(nuxt.options.buildDir, await resolveModulePath('@nuxt/vite-builder', { from: import.meta.url })) })
     if (typeof nuxt.options.builder === 'string' && nuxt.options.builder !== '@nuxt/vite-builder') {
-      opts.nodeReferences.push({ types: nuxt.options.builder })
+      try {
+        opts.nodeReferences.push({ types: relative(nuxt.options.buildDir, await resolveModulePath(nuxt.options.builder, { from: import.meta.url })) })
+      } catch {
+        // Fallback to bare package name for TypeScript resolution
+        opts.nodeReferences.push({ types: nuxt.options.builder })
+      }
     }

Alternatively, verify that the current approach (bare package name) is intentional for custom builders and document this difference in behaviour.

packages/schema/src/types/config.ts (1)

129-131: ViteOptions hook looks good

Neat way to expose a builder-augmentable surface without touching the existing config contract. 👍

packages/schema/src/types/schema.ts (2)

1243-1247: Nice addition for the env API toggle

The dedicated flag keeps experimental Vite environment wiring explicit and matches the surrounding experimental options.


1660-1660: ViteOptions swap aligns with builder augmentations

Updating ConfigSchema['vite'] to the new ViteOptions surface gives builders room to extend types without leaking those extras globally. 👍

packages/vite/src/index.ts (1)

1-19: Augmentation looks on point

Import-only dependency keeps runtime clean, and the merged $client, $server, and viteNode hooks bring the old shape back under the Vite builder umbrella.

packages/schema/src/index.ts (1)

4-11: Great to see the extra exports

Exporting ViteOptions (and the additional module/router/debug types) gives external consumers parity with the internal surface.

opts.nodeReferences.push({ path: resolve(nuxt.options.buildDir, 'types/runtime-config.d.ts') })
opts.nodeReferences.push({ path: resolve(nuxt.options.buildDir, 'types/app.config.d.ts') })
opts.nodeReferences.push({ types: 'nuxt' })
opts.nodeReferences.push({ types: relative(nuxt.options.buildDir, resolveModulePath('@nuxt/vite-builder', { from: import.meta.url })) })
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Missing await for async resolveModulePath call.

resolveModulePath is an async function that returns a Promise<string>, but it's being called without await. This will pass a Promise object to relative() instead of the resolved path string, causing type generation to fail.

Apply this diff to fix the issue:

-    opts.nodeReferences.push({ types: relative(nuxt.options.buildDir, resolveModulePath('@nuxt/vite-builder', { from: import.meta.url })) })
+    opts.nodeReferences.push({ types: relative(nuxt.options.buildDir, await resolveModulePath('@nuxt/vite-builder', { from: import.meta.url })) })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
opts.nodeReferences.push({ types: relative(nuxt.options.buildDir, resolveModulePath('@nuxt/vite-builder', { from: import.meta.url })) })
opts.nodeReferences.push({
types: relative(
nuxt.options.buildDir,
await resolveModulePath('@nuxt/vite-builder', { from: import.meta.url })
)
})
🤖 Prompt for AI Agents
In packages/nuxt/src/core/nuxt.ts around line 254, the call to resolveModulePath
is async but is not awaited, so relative() receives a Promise; change the call
to await resolveModulePath(...) (i.e. pass the resolved string to relative) and
ensure the enclosing function is declared async (or otherwise awaiting this
operation) so the await is valid.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 8, 2025

Open in StackBlitz

@nuxt/kit

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: ece6fa1

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 8, 2025

CodSpeed Performance Report

Merging #33427 will not alter performance

Comparing refactor/vite-augments (ece6fa1) with main (eca36cf)

Summary

✅ 10 untouched

@danielroe danielroe merged commit 8d8a7e0 into main Oct 8, 2025
84 of 85 checks passed
@danielroe danielroe deleted the refactor/vite-augments branch October 8, 2025 14:16
@github-actions github-actions bot mentioned this pull request Oct 8, 2025
@github-actions github-actions bot mentioned this pull request Oct 23, 2025
@github-actions github-actions bot mentioned this pull request Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants