feat(kit): add updateAppConfig util for module authors#35651
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds and exports the Nuxt Kit Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 14
🧹 Nitpick comments (1)
packages/kit/src/app-config.ts (1)
8-8: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
AppConfigInputforupdateAppConfig.Record<string, unknown>drops IntelliSense for standard app config keys; switch toAppConfigInputfrom@nuxt/schemaand updatedocs/4.api/5.kit/11.app-config.mdto match.🤖 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/src/app-config.ts` at line 8, Update the updateAppConfig function parameter from Record<string, unknown> to AppConfigInput imported from `@nuxt/schema`, preserving its existing behavior while restoring IntelliSense for standard app configuration keys. Update the corresponding updateAppConfig signature in 11.app-config.md to use AppConfigInput as well.
🤖 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.
Inline comments:
In `@docs/4.api/5.kit/12.nitro.md`:
- Around line 176-181: Update the useNitro example in the defineNuxtModule setup
to remove the unused createResolver call and its resolver variable, unless the
resolver is imported and meaningfully used; ensure the example is self-contained
and copyable.
- Around line 372-383: Update the documented signatures for both
addServerImportsDir and addServerScanDir so opts is optional, matching the
implementation’s default empty options object; omit the parameter only where the
implementation does not use it.
- Around line 202-204: Update the plugin documentation warning in the
`12.nitro.md` example to replace the empty import specifier with `nitro` for
`definePlugin`, matching the established import source used by the example
below.
- Around line 330-338: Update the documented addServerImports function signature
to name its parameter imports instead of dirs, matching the implementation and
the Parameters description; leave the type and return value unchanged.
In `@docs/4.api/5.kit/13.resolving.md`:
- Around line 187-194: Update the Return Value table’s resolve property
documentation to use the variadic signature accepted by
createResolver().resolve, showing multiple string path segments rather than a
single path argument. Leave resolvePath unchanged.
- Around line 30-48: Update the resolvePath and findPath option documentation in
13.resolving.md to include the resolver selector options: document options.type
and its pathType values, stating that pathType defaults to 'file' and also
supports 'dir'. Add the missing findPath directory-resolution API details and
correct any existing default-behavior descriptions without changing unrelated
options.
In `@docs/4.api/5.kit/15.builder.md`:
- Line 11: Update the introductory sentence in the builder documentation to use
“Nuxt has builders” instead of “Nuxt have builders,” leaving the remaining
explanation unchanged.
- Around line 315-317: Update the pluginFactory parameter documentation to
describe it as an object with optional vite, webpack, and rspack callbacks,
rather than as a factory function. Clarify that each callback returns the
corresponding plugin instance or supported array of instances.
- Around line 15-19: Update the deprecation warning in the extendViteConfig
documentation to apply only when using the server/client options for
environment-specific configuration. Keep extendViteConfig documented as the
general Vite configuration hook, while retaining the recommendation to use a
Vite config plugin or applyToEnvironment for scoped configuration.
- Around line 78-84: Update the extendViteConfig type example to show that its
callback may return Thenable<void>, and revise the affected plugin signature
examples to represent async plugin factories. Keep the existing ViteConfig,
ExtendViteConfigOptions, and synchronous forms where they remain supported.
- Around line 96-102: Remove the `prepend` option row from the
`extendViteConfig` and `extendWebpackConfig` option tables. Keep `prepend`
documented only for the plugin-registration helpers `addVitePlugin`,
`addWebpackPlugin`, and `addBuildPlugin`, where ordering behavior is supported.
In `@docs/4.api/5.kit/16.examples.md`:
- Around line 23-34: Clarify in the example around loadNuxt and the vite:extend
hook that overrides: { ssr: false } loads only the client-side build
configuration. Keep the override if client-only inspection is intended, and
explicitly state that the result does not represent the full SSR-enabled project
configuration.
In `@docs/4.api/5.kit/17.layers.md`:
- Line 125: Update the layer label in the logging expression near
getLayerDirectories so only the user layer is identified as user; do not infer
that every non-user index is base. Use a neutral layer label or derive the
actual layer type from available metadata, while preserving the existing
component count output.
In `@packages/kit/test/app-config.test.ts`:
- Around line 13-39: Ensure Nuxt cleanup runs even when assertions fail: in
packages/kit/test/app-config.test.ts ranges 13-39, 41-58, and 60-78, wrap each
test’s updateAppConfig and expect logic in try blocks and move the corresponding
await nuxt.close() calls into finally blocks.
---
Nitpick comments:
In `@packages/kit/src/app-config.ts`:
- Line 8: Update the updateAppConfig function parameter from Record<string,
unknown> to AppConfigInput imported from `@nuxt/schema`, preserving its existing
behavior while restoring IntelliSense for standard app configuration keys.
Update the corresponding updateAppConfig signature in 11.app-config.md to use
AppConfigInput as well.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a148f1e8-398f-4766-9a31-c518fc71dc87
📒 Files selected for processing (10)
docs/4.api/5.kit/11.app-config.mddocs/4.api/5.kit/12.nitro.mddocs/4.api/5.kit/13.resolving.mddocs/4.api/5.kit/14.logging.mddocs/4.api/5.kit/15.builder.mddocs/4.api/5.kit/16.examples.mddocs/4.api/5.kit/17.layers.mdpackages/kit/src/app-config.tspackages/kit/src/index.tspackages/kit/test/app-config.test.ts
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 14
🧹 Nitpick comments (1)
packages/kit/src/app-config.ts (1)
8-8: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
AppConfigInputforupdateAppConfig.Record<string, unknown>drops IntelliSense for standard app config keys; switch toAppConfigInputfrom@nuxt/schemaand updatedocs/4.api/5.kit/11.app-config.mdto match.🤖 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/src/app-config.ts` at line 8, Update the updateAppConfig function parameter from Record<string, unknown> to AppConfigInput imported from `@nuxt/schema`, preserving its existing behavior while restoring IntelliSense for standard app configuration keys. Update the corresponding updateAppConfig signature in 11.app-config.md to use AppConfigInput as well.
🤖 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.
Inline comments:
In `@docs/4.api/5.kit/12.nitro.md`:
- Around line 176-181: Update the useNitro example in the defineNuxtModule setup
to remove the unused createResolver call and its resolver variable, unless the
resolver is imported and meaningfully used; ensure the example is self-contained
and copyable.
- Around line 372-383: Update the documented signatures for both
addServerImportsDir and addServerScanDir so opts is optional, matching the
implementation’s default empty options object; omit the parameter only where the
implementation does not use it.
- Around line 202-204: Update the plugin documentation warning in the
`12.nitro.md` example to replace the empty import specifier with `nitro` for
`definePlugin`, matching the established import source used by the example
below.
- Around line 330-338: Update the documented addServerImports function signature
to name its parameter imports instead of dirs, matching the implementation and
the Parameters description; leave the type and return value unchanged.
In `@docs/4.api/5.kit/13.resolving.md`:
- Around line 187-194: Update the Return Value table’s resolve property
documentation to use the variadic signature accepted by
createResolver().resolve, showing multiple string path segments rather than a
single path argument. Leave resolvePath unchanged.
- Around line 30-48: Update the resolvePath and findPath option documentation in
13.resolving.md to include the resolver selector options: document options.type
and its pathType values, stating that pathType defaults to 'file' and also
supports 'dir'. Add the missing findPath directory-resolution API details and
correct any existing default-behavior descriptions without changing unrelated
options.
In `@docs/4.api/5.kit/15.builder.md`:
- Line 11: Update the introductory sentence in the builder documentation to use
“Nuxt has builders” instead of “Nuxt have builders,” leaving the remaining
explanation unchanged.
- Around line 315-317: Update the pluginFactory parameter documentation to
describe it as an object with optional vite, webpack, and rspack callbacks,
rather than as a factory function. Clarify that each callback returns the
corresponding plugin instance or supported array of instances.
- Around line 15-19: Update the deprecation warning in the extendViteConfig
documentation to apply only when using the server/client options for
environment-specific configuration. Keep extendViteConfig documented as the
general Vite configuration hook, while retaining the recommendation to use a
Vite config plugin or applyToEnvironment for scoped configuration.
- Around line 78-84: Update the extendViteConfig type example to show that its
callback may return Thenable<void>, and revise the affected plugin signature
examples to represent async plugin factories. Keep the existing ViteConfig,
ExtendViteConfigOptions, and synchronous forms where they remain supported.
- Around line 96-102: Remove the `prepend` option row from the
`extendViteConfig` and `extendWebpackConfig` option tables. Keep `prepend`
documented only for the plugin-registration helpers `addVitePlugin`,
`addWebpackPlugin`, and `addBuildPlugin`, where ordering behavior is supported.
In `@docs/4.api/5.kit/16.examples.md`:
- Around line 23-34: Clarify in the example around loadNuxt and the vite:extend
hook that overrides: { ssr: false } loads only the client-side build
configuration. Keep the override if client-only inspection is intended, and
explicitly state that the result does not represent the full SSR-enabled project
configuration.
In `@docs/4.api/5.kit/17.layers.md`:
- Line 125: Update the layer label in the logging expression near
getLayerDirectories so only the user layer is identified as user; do not infer
that every non-user index is base. Use a neutral layer label or derive the
actual layer type from available metadata, while preserving the existing
component count output.
In `@packages/kit/test/app-config.test.ts`:
- Around line 13-39: Ensure Nuxt cleanup runs even when assertions fail: in
packages/kit/test/app-config.test.ts ranges 13-39, 41-58, and 60-78, wrap each
test’s updateAppConfig and expect logic in try blocks and move the corresponding
await nuxt.close() calls into finally blocks.
---
Nitpick comments:
In `@packages/kit/src/app-config.ts`:
- Line 8: Update the updateAppConfig function parameter from Record<string,
unknown> to AppConfigInput imported from `@nuxt/schema`, preserving its existing
behavior while restoring IntelliSense for standard app configuration keys.
Update the corresponding updateAppConfig signature in 11.app-config.md to use
AppConfigInput as well.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a148f1e8-398f-4766-9a31-c518fc71dc87
📒 Files selected for processing (10)
docs/4.api/5.kit/11.app-config.mddocs/4.api/5.kit/12.nitro.mddocs/4.api/5.kit/13.resolving.mddocs/4.api/5.kit/14.logging.mddocs/4.api/5.kit/15.builder.mddocs/4.api/5.kit/16.examples.mddocs/4.api/5.kit/17.layers.mdpackages/kit/src/app-config.tspackages/kit/src/index.tspackages/kit/test/app-config.test.ts
🛑 Comments failed to post (14)
docs/4.api/5.kit/12.nitro.md (4)
176-181: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Fix the
useNitroexample.
createResolveris referenced but not imported, and the resultingresolveris unused. Remove those lines or import and use the resolver so the example is copyable.🤖 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 `@docs/4.api/5.kit/12.nitro.md` around lines 176 - 181, Update the useNitro example in the defineNuxtModule setup to remove the unused createResolver call and its resolver variable, unless the resolver is imported and meaningfully used; ensure the example is self-contained and copyable.
202-204: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail # Inspect the target file around the cited lines. file="docs/4.api/5.kit/12.nitro.md" wc -l "$file" sed -n '180,230p' "$file" # Look for the symbol and related import examples in the docs tree. rg -n "definePlugin|useRuntimeConfig|import .*from ``|from 'nitro'|from \"nitro\"" docs -SRepository: nuxt/nuxt
Length of output: 43238
Replace the empty import specifier with
nitro. Indocs/4.api/5.kit/12.nitro.md,definePluginshould be imported from'nitro'here, matching the example below.🧰 Tools
🪛 LanguageTool
[uncategorized] ~203-~203: Loose punctuation mark.
Context: ...o utilities such asuseRuntimeConfig. :: ### Usage ```ts twoslash import { ad...(UNLIKELY_OPENING_PUNCTUATION)
🤖 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 `@docs/4.api/5.kit/12.nitro.md` around lines 202 - 204, Update the plugin documentation warning in the `12.nitro.md` example to replace the empty import specifier with `nitro` for `definePlugin`, matching the established import source used by the example below.
330-338: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail # Locate the documentation snippet and the source signature it cites. git ls-files 'docs/4.api/5.kit/12.nitro.md' 'packages/kit/src/nitro.ts' echo '--- docs excerpt ---' sed -n '320,345p' docs/4.api/5.kit/12.nitro.md echo '--- source excerpt ---' sed -n '1,220p' packages/kit/src/nitro.tsRepository: nuxt/nuxt
Length of output: 5024
🏁 Script executed:
#!/bin/bash set -euo pipefail # Check whether the parameter name is referenced elsewhere in docs or source. rg -n --hidden --no-ignore-vcs '\baddServerImports\b|\bdirs\b|\bimports\b' docs packages/kit/src/nitro.tsRepository: nuxt/nuxt
Length of output: 29227
🏁 Script executed:
#!/bin/bash set -euo pipefail python3 - <<'PY' from pathlib import Path p = Path('packages/kit/src/nitro.ts') if p.exists(): text = p.read_text() idx = text.find('addServerImports') print(text[max(0, idx-200):idx+400] if idx != -1 else 'not found') PYRepository: nuxt/nuxt
Length of output: 748
🏁 Script executed:
#!/bin/bash set -euo pipefail # If the docs file references a generated API table, inspect surrounding headings too. sed -n '300,360p' docs/4.api/5.kit/12.nitro.mdRepository: nuxt/nuxt
Length of output: 3255
Rename the
addServerImportssignature parameter toimports. Indocs/4.api/5.kit/12.nitro.md:333, the signature should match the implementation and the parameter description below;dirsrefers to the directory-scanning API instead.🧰 Tools
🪛 LanguageTool
[uncategorized] ~338-~338: Loose punctuation mark.
Context: ...[]): void ``` ### Parametersimports: An object or an array of objects with t...(UNLIKELY_OPENING_PUNCTUATION)
🤖 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 `@docs/4.api/5.kit/12.nitro.md` around lines 330 - 338, Update the documented addServerImports function signature to name its parameter imports instead of dirs, matching the implementation and the Parameters description; leave the type and return value unchanged.
372-383: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== docs excerpt ==" sed -n '360,390p' docs/4.api/5.kit/12.nitro.md echo sed -n '446,475p' docs/4.api/5.kit/12.nitro.md echo echo "== source excerpt ==" sed -n '1,220p' packages/kit/src/nitro.tsRepository: nuxt/nuxt
Length of output: 6197
Mark
optsoptional in both directory-helper signatures. The docs showoptsas required in bothaddServerImportsDirandaddServerScanDir, but the implementation defaults it to{}. Change the signatures toopts?: { prepend?: boolean }or omit the parameter where it is unused.🤖 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 `@docs/4.api/5.kit/12.nitro.md` around lines 372 - 383, Update the documented signatures for both addServerImportsDir and addServerScanDir so opts is optional, matching the implementation’s default empty options object; omit the parameter only where the implementation does not use it.docs/4.api/5.kit/13.resolving.md (2)
30-48: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail # Map the relevant files and inspect the doc section plus the resolver implementation. printf '\n== Files ==\n' git ls-files 'docs/4.api/5.kit/13.resolving.md' 'packages/kit/src/resolve.ts' printf '\n== Doc file (around lines 1-220) ==\n' sed -n '1,220p' docs/4.api/5.kit/13.resolving.md | cat -n printf '\n== Resolver implementation outline ==\n' ast-grep outline packages/kit/src/resolve.ts --view expanded printf '\n== Resolver implementation (around likely relevant sections) ==\n' sed -n '1,260p' packages/kit/src/resolve.ts | cat -nRepository: nuxt/nuxt
Length of output: 20968
Document the missing resolver selector options. In
docs/4.api/5.kit/13.resolving.md(resolvePathandfindPath), addoptions.typeand show thatpathTypedefaults to'file'and also accepts'dir'. The current docs miss the directory-resolution API and misstate the default behaviour.🧰 Tools
🪛 LanguageTool
[uncategorized] ~38-~38: Loose punctuation mark.
Context: ... ``` ### Parameterspath: A path to resolve. `options`: Opti...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~40-~40: Loose punctuation mark.
Context: ...th**: A path to resolve. **options`**: Options to pass to the resolver. This o...(UNLIKELY_OPENING_PUNCTUATION)
[grammar] ~48-~48: The word “fallback” is a noun. The verb is spelled with a white space.
Context: ... |false| Whether to fallback to the original path if the resolved pa...(NOUN_VERB_CONFUSION)
🤖 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 `@docs/4.api/5.kit/13.resolving.md` around lines 30 - 48, Update the resolvePath and findPath option documentation in 13.resolving.md to include the resolver selector options: document options.type and its pathType values, stating that pathType defaults to 'file' and also supports 'dir'. Add the missing findPath directory-resolution API details and correct any existing default-behavior descriptions without changing unrelated options.
187-194: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail printf '\n## files\n' git ls-files 'docs/4.api/5.kit/13.resolving.md' 'packages/kit/src/resolve.ts' printf '\n## resolve.ts outline\n' ast-grep outline packages/kit/src/resolve.ts --view expanded || true printf '\n## docs excerpt\n' sed -n '180,200p' docs/4.api/5.kit/13.resolving.md printf '\n## resolve.ts excerpt\n' sed -n '1,220p' packages/kit/src/resolve.tsRepository: nuxt/nuxt
Length of output: 9283
Match the variadic
resolvesignature.createResolver().resolveaccepts multiple path segments (resolve(...path: string[])), but the return-value table still documents a singlepath: stringargument. Update it to match the actual API.🤖 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 `@docs/4.api/5.kit/13.resolving.md` around lines 187 - 194, Update the Return Value table’s resolve property documentation to use the variadic signature accepted by createResolver().resolve, showing multiple string path segments rather than a single path argument. Leave resolvePath unchanged.docs/4.api/5.kit/15.builder.md (5)
11-11: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the page introduction grammar.
Use “Nuxt has builders” rather than “Nuxt have builders”.
🤖 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 `@docs/4.api/5.kit/15.builder.md` at line 11, Update the introductory sentence in the builder documentation to use “Nuxt has builders” instead of “Nuxt have builders,” leaving the remaining explanation unchanged.Source: Linters/SAST tools
15-19: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail printf '\n## docs snippet\n' sed -n '1,80p' docs/4.api/5.kit/15.builder.md printf '\n## source matches\n' rg -n "extendViteConfig|applyToEnvironment|deprecated|server|client" packages/kit/src/build.ts docs/4.api/5.kit/15.builder.mdRepository: nuxt/nuxt
Length of output: 11281
🏁 Script executed:
#!/bin/bash set -euo pipefail printf '\n## build.ts outline\n' ast-grep outline packages/kit/src/build.ts --view expanded || true printf '\n## relevant source excerpt\n' nl -ba packages/kit/src/build.ts | sed -n '1,260p'Repository: nuxt/nuxt
Length of output: 2252
🏁 Script executed:
#!/bin/bash set -euo pipefail sed -n '111,220p' packages/kit/src/build.ts | cat -nRepository: nuxt/nuxt
Length of output: 4996
Scope the deprecation warning to the
server/clientoptions.extendViteConfigitself is still the general hook for Vite config; only the environment-specific usage is deprecated, so the docs should not mark the whole API as deprecated.docs/4.api/5.kit/15.builder.md:15-19🧰 Tools
🪛 LanguageTool
[uncategorized] ~15-~15: Possible missing article found.
Context: ...onfig` Extends the Vite configuration. Callback function can be called multiple times, ...(AI_HYDRA_LEO_MISSING_THE)
[uncategorized] ~16-~16: Loose punctuation mark.
Context: ...ying to both client and server builds. ::warning This hook is now deprecated, an...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~18-~18: Loose punctuation mark.
Context: ... — theapplyToEnvironmenthook. :: ### Usage ```ts twoslash import { de...(UNLIKELY_OPENING_PUNCTUATION)
🤖 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 `@docs/4.api/5.kit/15.builder.md` around lines 15 - 19, Update the deprecation warning in the extendViteConfig documentation to apply only when using the server/client options for environment-specific configuration. Keep extendViteConfig documented as the general Vite configuration hook, while retaining the recommendation to use a Vite config plugin or applyToEnvironment for scoped configuration.
78-84: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail # Map the relevant files first printf '\n== file list ==\n' git ls-files 'docs/4.api/5.kit/15.builder.md' 'packages/kit/src/build.ts' printf '\n== docs outline ==\n' ast-grep outline docs/4.api/5.kit/15.builder.md --view expanded || true printf '\n== source outline ==\n' ast-grep outline packages/kit/src/build.ts --view expanded || true printf '\n== docs excerpts ==\n' sed -n '60,340p' docs/4.api/5.kit/15.builder.md printf '\n== source excerpts ==\n' sed -n '1,260p' packages/kit/src/build.tsRepository: nuxt/nuxt
Length of output: 24249
🏁 Script executed:
#!/bin/bash set -euo pipefail sed -n '70,90p' docs/4.api/5.kit/15.builder.md printf '\n---\n' sed -n '1,220p' packages/kit/src/build.tsRepository: nuxt/nuxt
Length of output: 8187
🌐 Web query:
Nuxt kit build.ts extendViteConfig thenable callback plugin getter async types raw.githubusercontent.com💡 Result:
In Nuxt Kit, the utilities used to modify build configurations, such as addVitePlugin and extendViteConfig, have been updated to support asynchronous operations [1]. Core improvements in recent versions (specifically visible in packages/kit/src/build.ts) include: 1. Support for Thenable Values: The build APIs, including addVitePlugin, have been updated to accept and handle Thenable types [1]. This allows for async plugin getters, which are particularly useful for lazy-loading plugins via dynamic imports [2][1]. 2. Asynchronous Plugin Getters: When using addVitePlugin, the pluginOrGetter parameter now supports a function that returns a Promise (or is async), allowing the plugin to be loaded or constructed asynchronously [2][3]. Internally, the Kit utilities now await these getters before registering them [1][3]. 3. Implementation Pattern: Within the Nuxt Kit source code, the pattern used is
typeof pluginOrGetter === 'function' ? await pluginOrGetter() : pluginOrGetter[3][4]. This ensures that if a factory function is provided, the library properly awaits its result before proceeding [1]. Important Deprecation Note: While extendViteConfig remains available in some versions, it is increasingly deprecated in favor of using standard Vite plugins [2][5]. For modern Nuxt development (especially Nuxt 5+), you should transition to using addVitePlugin, which offers better support for environment-specific configuration via hooks like applyToEnvironment or configEnvironment [6][7]. If you are inspecting the source code on GitHub (e.g., raw.githubusercontent.com), you will observe that these functions have evolved to include proper TypeScript support for Thenable and Arrayable types, ensuring that both synchronous plugin instances and asynchronous factories are handled robustly [1][3][4].Citations:
- 1: #33619
- 2: https://nuxt.com/docs/4.x/api/kit/builder
- 3: https://github.com/nuxt/nuxt/blob/main/packages/kit/src/build.ts
- 4: https://github.com/nuxt/nuxt/blob/1dc113c9/packages/kit/src/build.ts
- 5: https://www.mintlify.com/nuxt/nuxt/api/kit/builder
- 6: https://nuxt.com/docs/5.x/getting-started/upgrade
- 7: https://docs.iranisoft.ir/nuxtjs/4.4.x/4.api/5.kit/14.builder
🏁 Script executed:
#!/bin/bash set -euo pipefail # Show the other referenced type blocks with line numbers nl -ba docs/4.api/5.kit/15.builder.md | sed -n '120,145p' printf '\n---\n' nl -ba docs/4.api/5.kit/15.builder.md | sed -n '190,215p' printf '\n---\n' nl -ba docs/4.api/5.kit/15.builder.md | sed -n '260,285p' printf '\n---\n' nl -ba docs/4.api/5.kit/15.builder.md | sed -n '295,325p'Repository: nuxt/nuxt
Length of output: 187
🏁 Script executed:
#!/bin/bash set -euo pipefail nl -ba docs/4.api/5.kit/15.builder.md | sed -n '120,145p' printf '\n---\n' nl -ba docs/4.api/5.kit/15.builder.md | sed -n '190,215p' printf '\n---\n' nl -ba docs/4.api/5.kit/15.builder.md | sed -n '260,285p' printf '\n---\n' nl -ba docs/4.api/5.kit/15.builder.md | sed -n '295,325p'Repository: nuxt/nuxt
Length of output: 187
🏁 Script executed:
#!/bin/bash set -euo pipefail awk 'NR>=120 && NR<=145 {printf "%5d %s\n", NR, $0}' docs/4.api/5.kit/15.builder.md printf '\n---\n' awk 'NR>=190 && NR<=215 {printf "%5d %s\n", NR, $0}' docs/4.api/5.kit/15.builder.md printf '\n---\n' awk 'NR>=260 && NR<=285 {printf "%5d %s\n", NR, $0}' docs/4.api/5.kit/15.builder.md printf '\n---\n' awk 'NR>=295 && NR<=325 {printf "%5d %s\n", NR, $0}' docs/4.api/5.kit/15.builder.mdRepository: nuxt/nuxt
Length of output: 5876
Show the async/thenable forms in the type examples. The type snippets in
docs/4.api/5.kit/15.builder.mdstill show synchronous callback/plugin signatures, but the API acceptsThenable<void>and async plugin factories. Update the affected blocks to match the supported forms.🤖 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 `@docs/4.api/5.kit/15.builder.md` around lines 78 - 84, Update the extendViteConfig type example to show that its callback may return Thenable<void>, and revise the affected plugin signature examples to represent async plugin factories. Keep the existing ViteConfig, ExtendViteConfigOptions, and synchronous forms where they remain supported.
96-102: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail echo '--- docs/4.api/5.kit/15.builder.md (relevant ranges) ---' sed -n '80,170p' docs/4.api/5.kit/15.builder.md echo echo '--- search for prepend in kit source/docs ---' rg -n "prepend" packages/kit docs/4.api/5.kit/15.builder.md echo echo '--- packages/kit/src/build.ts (outline) ---' ast-grep outline packages/kit/src/build.ts --view expandedRepository: nuxt/nuxt
Length of output: 9891
🏁 Script executed:
#!/bin/bash set -euo pipefail # Focus on the build helpers and their option types. rg -n -C 3 "prepend|extendViteConfig|extendWebpackConfig|addVitePlugin|addWebpackPlugin" packages/kit/src/build.ts docs/4.api/5.kit/15.builder.md # Show only the relevant source slices if the file is not huge. lines=$(wc -l < packages/kit/src/build.ts) echo "build.ts lines: $lines" if [ "$lines" -le 500 ]; then sed -n '1,260p' packages/kit/src/build.ts else sed -n '1,220p' packages/kit/src/build.ts sed -n '220,420p' packages/kit/src/build.ts fiRepository: nuxt/nuxt
Length of output: 29747
Remove
prependfrom theextendViteConfigandextendWebpackConfigoption tables.prependonly affects the plugin-registration helpers (addVitePlugin/addWebpackPlugin/addBuildPlugin); these config-extension callbacks ignore it, so the docs currently promise ordering behaviour they do not provide.🤖 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 `@docs/4.api/5.kit/15.builder.md` around lines 96 - 102, Remove the `prepend` option row from the `extendViteConfig` and `extendWebpackConfig` option tables. Keep `prepend` documented only for the plugin-registration helpers `addVitePlugin`, `addWebpackPlugin`, and `addBuildPlugin`, where ordering behavior is supported.
315-317: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail printf '\n## build.ts references\n' git ls-files | rg '^packages/kit/src/build\.ts$|^docs/4\.api/5\.kit/15\.builder\.md$' printf '\n## ast-grep outline: packages/kit/src/build.ts\n' ast-grep outline packages/kit/src/build.ts --view expanded || true printf '\n## relevant doc lines\n' sed -n '300,330p' docs/4.api/5.kit/15.builder.md | cat -n printf '\n## relevant source lines\n' sed -n '1,260p' packages/kit/src/build.ts | cat -nRepository: nuxt/nuxt
Length of output: 14260
Describe
pluginFactoryas an object with optionalvite,webpack, andrspackcallbacks. The current text calls it a factory function and leaves outrspack.🧰 Tools
🪛 LanguageTool
[uncategorized] ~317-~317: Loose punctuation mark.
Context: ...``` ### ParameterspluginFactory: A factory function that returns an obje...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~317-~317: Possible missing comma found.
Context: ...gin instance or an array of Vite plugin instances and/or a webpack plugin instance or an ...(AI_HYDRA_LEO_MISSING_COMMA)
🤖 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 `@docs/4.api/5.kit/15.builder.md` around lines 315 - 317, Update the pluginFactory parameter documentation to describe it as an object with optional vite, webpack, and rspack callbacks, rather than as a factory function. Clarify that each callback returns the corresponding plugin instance or supported array of instances.docs/4.api/5.kit/16.examples.md (1)
23-34: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail echo '--- docs/4.api/5.kit/16.examples.md (around lines 1-80) ---' sed -n '1,80p' docs/4.api/5.kit/16.examples.md echo echo '--- search for loadNuxt / vite:extend / ssr false in docs ---' rg -n "loadNuxt|vite:extend|overrides:\s*\{\s*ssr:\s*false\s*\}" docs -S echo echo '--- search repository-wide for overrides ssr false ---' rg -n "overrides:\s*\{\s*ssr:\s*false\s*\}" -S .Repository: nuxt/nuxt
Length of output: 5842
🏁 Script executed:
#!/bin/bash set -euo pipefail sed -n '1,80p' docs/4.api/5.kit/16.examples.md rg -n "loadNuxt|vite:extend|overrides:\s*\{\s*ssr:\s*false\s*\}" docs -S rg -n "overrides:\s*\{\s*ssr:\s*false\s*\}" -S .Repository: nuxt/nuxt
Length of output: 5663
🌐 Web query:
Nuxt loadNuxt overrides ssr false vite:extend client-only configuration💡 Result:
When using Nuxt programmatically with loadNuxt, you can override configuration options—including ssr: false—by passing an overrides object [1][2]. To effectively interact with the Vite configuration during this programmatic process, you should use the vite:extendConfig hook [3][4][5]. To override settings and extend Vite configuration programmatically: 1. Use loadNuxt from
@nuxt/kit, providing an overrides object in the loadOptions to set ssr: false [1][2]. 2. Register a hook for vite:extendConfig on the returned Nuxt instance before building [4][5]. Example implementation: import { loadNuxt, buildNuxt } from '@nuxt/kit'; async function getViteConfig { // Load Nuxt with overrides const nuxt = await loadNuxt({ cwd: process.cwd, dev: false, overrides: { ssr: false } }); return new Promise((resolve, reject) => { // Extend or inspect Vite config nuxt.hook('vite:extendConfig', (config) => { // Modify config here resolve(config); throw new Error('stop'); // Stop build after config inspection }); buildNuxt(nuxt).catch((err) => { if (!err.toString.includes('stop')) reject(err); }); }).finally( => nuxt.close); } Regarding the ClientOnly component: It is a built-in Nuxt component used to defer rendering until the client-side has mounted [6]. When ssr: false is set globally, the entire application is treated as client-only, which makes the ClientOnly component behave differently (or redundantly) since the server-side rendering phase is effectively bypassed [7][8]. If you encounter issues where components are incorrectly detected as server components when ssr: false is active, ensure you are using a modern version of Nuxt, as this has been addressed in previous maintenance updates [9].Citations:
- 1: https://nuxt.com/docs/4.x/api/kit/programmatic
- 2: #24197
- 3: https://vite.nuxtjs.org/advanced/modules/
- 4: #14534
- 5: cypress-io/cypress#23619
- 6: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/components/client-only.ts
- 7: https://nuxt.com/docs/3.x/guide/concepts/rendering
- 8: https://nuxt.com/docs/4.x/guide/concepts/rendering
- 9: #26334
🏁 Script executed:
#!/bin/bash set -euo pipefail echo '--- docs/4.api/6.advanced/1.hooks.md around vite hooks ---' sed -n '60,95p' docs/4.api/6.advanced/1.hooks.md echo echo '--- docs/4.api/5.kit/2.programmatic.md loadNuxt section ---' sed -n '1,45p' docs/4.api/5.kit/2.programmatic.mdRepository: nuxt/nuxt
Length of output: 14492
Clarify that this only inspects the client-side Vite config.
overrides: { ssr: false }changes which Nuxt build is loaded, so this example does not reflect the full SSR-enabled project config. Either remove the override or say explicitly that the lookup is client-only.🤖 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 `@docs/4.api/5.kit/16.examples.md` around lines 23 - 34, Clarify in the example around loadNuxt and the vite:extend hook that overrides: { ssr: false } loads only the client-side build configuration. Keep the override if client-only inspection is intended, and explicitly state that the result does not represent the full SSR-enabled project configuration.docs/4.api/5.kit/17.layers.md (1)
125-125: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not label every non-user layer as
base.
getLayerDirectories()can include extended or intermediate layers, not only the user layer and base layers. Use a neutral label such aslayer ${index}, or distinguish actual layer types from metadata rather than inferring them from the index.🤖 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 `@docs/4.api/5.kit/17.layers.md` at line 125, Update the layer label in the logging expression near getLayerDirectories so only the user layer is identified as user; do not infer that every non-user index is base. Use a neutral layer label or derive the actual layer type from available metadata, while preserving the existing component count output.packages/kit/test/app-config.test.ts (1)
13-39: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Ensure the Nuxt instance is always closed to prevent context leaks.
In all three tests,
await nuxt.close()is called after theexpectassertion. If an assertion fails, an error is thrown and the Nuxt instance is left open, which can leak the context into the next test and cause cascading failures. Wrap the test logic in atry...finallyblock to ensure cleanup always occurs.
packages/kit/test/app-config.test.ts#L13-L39: WrapupdateAppConfigandexpectin atryblock and moveawait nuxt.close()to thefinallyblock.packages/kit/test/app-config.test.ts#L41-L58: Apply the sametry...finallypattern for cleanup.packages/kit/test/app-config.test.ts#L60-L78: Apply the sametry...finallypattern for cleanup.📍 Affects 1 file
packages/kit/test/app-config.test.ts#L13-L39(this comment)packages/kit/test/app-config.test.ts#L41-L58packages/kit/test/app-config.test.ts#L60-L78🤖 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/app-config.test.ts` around lines 13 - 39, Ensure Nuxt cleanup runs even when assertions fail: in packages/kit/test/app-config.test.ts ranges 13-39, 41-58, and 60-78, wrap each test’s updateAppConfig and expect logic in try blocks and move the corresponding await nuxt.close() calls into finally blocks.
updateAppConfig util for module authors
Merging this PR will not alter performance
Comparing Footnotes
|
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
🔗 Linked issue
Resolves #27857
📚 Description
Introduces a new
updateAppConfigutil to @nuxt/kit which works similary to the existing updateRuntimeConfig util.I've also re-numbered the docs to keep the two updateXConfig utils together.