-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat(kit): support single import in addServerImports
#32289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(kit): support single import in addServerImports
#32289
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for passing a single import object to addServerImports
and includes its documentation.
- Updated
addServerImports
to acceptImport | Import[]
by normalizing viatoArray
- Pushed normalized imports into
config.imports.imports
in Nitro hook - Added API docs for
addServerImports
in the Nitro section
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
packages/kit/src/nitro.ts | Extended addServerImports signature and added array handling |
docs/3.api/5.kit/11.nitro.md | Added and documented addServerImports API |
Comments suppressed due to low confidence (3)
docs/3.api/5.kit/11.nitro.md:326
- The parameter name
dirs
doesn’t match the function signature, which usesimports
. Rename it toimports
for consistency.
function addServerImports (dirs: Import | Import[]): void
packages/kit/src/nitro.ts:89
- Add unit tests to cover the new single-import usage path of
addServerImports
to prevent regressions.
export function addServerImports (imports: Import | Import[]) {
packages/kit/src/nitro.ts:91
- Ensure that
toArray
is imported in this module; otherwise this will cause a runtime error.
const _imports = toArray(imports)
WalkthroughA new section was added to the Nitro API documentation describing the 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🧰 Additional context used🪛 LanguageTooldocs/3.api/5.kit/11.nitro.md[uncategorized] ~330-~330: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION) ⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (3)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📒 Files selected for processing (2)
docs/3.api/5.kit/11.nitro.md
(1 hunks)packages/kit/src/nitro.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/kit/src/nitro.ts (1)
packages/kit/src/utils.ts (1)
toArray
(2-4)
🪛 LanguageTool
docs/3.api/5.kit/11.nitro.md
[uncategorized] ~330-~330: Loose punctuation mark.
Context: ...[]): void ``` ### Parameters imports
: An object or an array of objects with t...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (12)
- GitHub Check: test-fixtures (windows-latest, dev, vite, default, manifest-on, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-off, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, built, rspack, default, manifest-on, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, built, webpack, default, manifest-on, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-off, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, js, 20)
- GitHub Check: test-benchmark
- GitHub Check: release-pr
- GitHub Check: typecheck (ubuntu-latest, bundler)
- GitHub Check: typecheck (windows-latest, bundler)
- GitHub Check: code
- GitHub Check: lint-docs
🔇 Additional comments (2)
packages/kit/src/nitro.ts (1)
89-97
: LGTM! Implementation correctly supports single import arguments.The function signature change and internal normalisation using
toArray
follows the established pattern used by other functions likeaddPrerenderRoutes
. This maintains backward compatibility whilst enabling the desired single import functionality.docs/3.api/5.kit/11.nitro.md (1)
296-342
: Excellent documentation addition following established patterns.The documentation is comprehensive, well-structured, and includes a practical usage example. The parameter table thoroughly describes all available import properties, which will be valuable for developers.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~330-~330: Loose punctuation mark.
Context: ...[]): void ``` ### Parametersimports
: An object or an array of objects with t...(UNLIKELY_OPENING_PUNCTUATION)
### Type | ||
|
||
```ts | ||
function addServerImports (dirs: Import | Import[]): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix parameter name inconsistency in type signature.
The function signature shows dirs
as the parameter name, but it should be imports
to match the actual implementation and parameter description.
-function addServerImports (dirs: Import | Import[]): void
+function addServerImports (imports: Import | Import[]): void
📝 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.
function addServerImports (dirs: Import | Import[]): void | |
function addServerImports (imports: Import | Import[]): void |
🤖 Prompt for AI Agents
In docs/3.api/5.kit/11.nitro.md at line 325, rename the parameter in the
function signature from 'dirs' to 'imports' to ensure consistency with the
actual implementation and parameter description.
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #32289 will not alter performanceComparing Summary
|
addServerImports
addServerImports
🔗 Linked issue
📚 Description
Noticed that
addServerImports
does not support passing a single import likeaddImports
does. I haven't actually tested the code changes, but I matched the logic ofaddServerImportsDir
.While adding this I noticed the documentation was missing
addServerImports
entirely so I added that as well, this is basically the same as the documentation foraddImports
, feels a bit weird to duplicate it...