-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix(nitro): include layer server directories in tsconfig.server.json #33510
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
base: main
Are you sure you want to change the base?
Conversation
Fixes an issue where server files inside Nuxt layer directories (e.g., layers/*/server/**) were not automatically included in .nuxt/tsconfig.server.json, causing IDEs to fail type resolution for Nitro types like defineNitroPlugin. Changes: - Add layer server directories to Nitro TypeScript config include - Add test to verify layer server paths are included in tsconfig Closes nuxt#33489
|
|
WalkthroughAdds additional TypeScript/JavaScript include globs to the Nitro/Nuxt server build so Nitro's tsconfig Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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). (2)
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.
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)
packages/nitro-server/src/index.ts(1 hunks)packages/nuxt/test/load-nuxt.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Follow standard TypeScript conventions and best practices
Files:
packages/nitro-server/src/index.tspackages/nuxt/test/load-nuxt.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for core functionality using
vitest
Files:
packages/nuxt/test/load-nuxt.test.ts
🧬 Code graph analysis (1)
packages/nuxt/test/load-nuxt.test.ts (2)
packages/nuxt/src/core/nuxt.ts (1)
loadNuxt(752-870)packages/kit/src/loader/nuxt.ts (1)
loadNuxt(18-37)
🪛 GitHub Check: build
packages/nuxt/test/load-nuxt.test.ts
[failure] 149-149:
Property '_nitro' does not exist on type 'Nuxt'.
⏰ 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). (2)
- GitHub Check: codeql (javascript-typescript)
- GitHub Check: code
🔇 Additional comments (1)
packages/nitro-server/src/index.ts (1)
217-217: LGTM! Correctly includes layer server directories in TypeScript configuration.This change aligns TypeScript IDE support with Nitro's runtime
scanDirsbehaviour (line 180), ensuring server files within layers receive proper type checking. The glob pattern**/*appropriately captures all server files, consistent with the objective to fix IDE TypeScript errors for layer server directories.
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #33510 will not alter performanceComparing Summary
|
The '**/*' glob was causing TypeScript to process all files including non-TS files, leading to performance issues and test timeouts. Changed to match the pattern used for module directories.
Changed from 'dirs.server' to 'dirs.server/**/*.{ts,tsx,mts,cts}'
- Ensures subdirectories like server/api/, server/middleware/ are included
- Only processes TypeScript files, avoiding performance issues
- Matches pattern used for shared directories
| ] | ||
| }), | ||
| ...layerDirs.flatMap((dirs) => { | ||
| const serverFileGlobs = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts', '**/*.js', '**/*.mjs', '**/*.cjs'] |
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.
couldn't we add just the server directory and not the individual extensions?
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.
- extensions are configureable from options: example knip https://github.com/webpro-nl/knip/pull/1265/files#diff-94cc8dab409c9b7cd7fc21a94d45b1fd23f3fd3c5eb2a152dea271fa1bbeff59R44
- we can combine them into one glob: https://github.com/webpro-nl/knip/pull/1265/files#diff-94cc8dab409c9b7cd7fc21a94d45b1fd23f3fd3c5eb2a152dea271fa1bbeff59R90
Fixes #33477
In Nuxt 4.1.3, server files inside layer directories (e.g.
layers/*/server/**) were not being included in the generated.nuxt/tsconfig.server.json. This caused TypeScript errors in IDEs such as WebStorm (e.g.Cannot find name 'defineNitroPlugin'), even though the application ran correctly.This change updates the TypeScript configuration generation to automatically include all layer server directories, matching how Nitro already includes them in its
scanDirsconfiguration.Changes
includearray in.nuxt/tsconfig.server.jsonnitro.typescript.tsConfig.includeLinked issue
Fixes #33477
Notes
This aligns the handling of layer server directories with the main server directory, improving TypeScript developer experience without affecting runtime behavior.