Repository navigation
fix(nitro): expose server auto-imports as #imports/server - #36039
chairulakmal wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughNuxt and Nitro expose server auto-imports through the Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 1
🤖 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 304-305: Update the documentation sentence describing the
`#imports/server` alias so it claims support only in the app and server type
contexts, preserving the existing server-route example and avoiding broader
claims about every type context.
🪄 Autofix
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 Plus
Run ID: f91a185f-3f9b-4d93-a7bc-68e249c54e4e
📒 Files selected for processing (12)
docs/3.guide/1.concepts/3.auto-imports.mddocs/3.guide/4.modules/5.recipes-advanced.mddocs/4.api/5.kit/12.nitro.mdpackages/kit/test/generate-types.spec.tspackages/nitro-server/src/index.tspackages/nuxt/test/load-nuxt.test.tstest/basic.test.tstest/fixtures/basic-types/modules/auto-registered/index.tstest/fixtures/basic-types/modules/auto-registered/runtime/server/utils/session.tstest/fixtures/basic-types/server/api/server-imports.tstest/fixtures/basic-types/server/utils/server-imports.tstest/fixtures/basic/server/api/server-imports.ts
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
Merging this PR will not alter performance
Comparing Footnotes
|
|
this was a good change - thank you ❤️ however, nitro v3 has now dropped auto-imports entirely, so this is resolved #36265 🎉 |
🔗 Linked issue
Resolves #33979
📚 Description
Nitro now registers a
#imports/serveralias pointing at thenitro-imports.d.tsit already generates, so server auto-imports can be imported explicitly from a specifier that resolves in every type context. It's mapped intsconfig.server.jsonand, through theprepare:typeshook, intsconfig.app.json, which the legacy.nuxt/tsconfig.jsoninherits; at runtime it's a Nitrovirtualentry re-exporting#imports, the same way Nitro already exposes#nitro. Deliberately not anuxt.options.aliasentry, so importing it from app code still fails the build instead of bundling server code into the client.It needs a second name because
nitro-routes.d.tsimports route handlers for$fetchreturn-type inference, which pulls server files into the app program, and there#importsis the app's auto-imports with nothing fromaddServerImportsdeclared. Since #35938 the server imports run regardless ofexperimental.nitroAutoImports, so this hits default v5 apps. Plain#importsin a server file stays broken in the app program and this PR doesn't change that: one specifier can't resolve to two different sets in two programs that both include the file.On naming, I said I'd wait for your confirmation before opening this. I went with
#imports/serversince it's the wording in the issue, but it's trivial to rename and the#imports/nuxt+#imports/nitropair is still on the table.Tests cover the tsconfig paths, the runtime virtual and the absence of an app alias, plus type-level fixtures for a route handler and a non-route server file and a runtime
$fetchassertion; docs updated in the auto-imports guide, the module recipes page and the Kit Nitro reference.