Skip to content

Conversation

@dheeraj3587
Copy link
Contributor

@dheeraj3587 dheeraj3587 commented Oct 15, 2025

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 scanDirs configuration.

Changes

  • Added layer server paths to the include array in .nuxt/tsconfig.server.json
  • Restored IDE TypeScript support for server files inside layers
  • Removed the need for manual configuration via nitro.typescript.tsConfig.include

Linked 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.

@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 15, 2025

Walkthrough

  • Added playground/layers/test-layer/nuxt.config.ts exporting a default Nuxt config via defineNuxtConfig.
  • Added playground/layers/test-layer/server/plugins/test.ts exporting a minimal Nitro plugin via defineNitroPlugin (no runtime logic).
  • Updated playground/nuxt.config.ts to include extends: ['./layers/test-layer'].
  • Modified packages/nitro-server/src/index.ts to broaden TypeScript include globs to encompass all files under each layer's server directory.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

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 (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "fix(nitro): include layer server directories in tsconfig.server.json" directly and clearly summarises the main change in the changeset. It is specific, concise, and accurately reflects the core objective of updating the TypeScript configuration to include layer server directories. The title aligns with both the PR description and the underlying issue #33477, providing a developer scanning the history with an immediate understanding of the primary change.
Linked Issues Check ✅ Passed The code changes directly address the primary objective from linked issue #33477. The modification to packages/nitro-server/src/index.ts adds an additional glob pattern to the TypeScript include configuration, which automatically includes all files under layer server directories in the generated .nuxt/tsconfig.server.json file. This resolves the reported issue where server files inside layers were not being included, which was causing IDE TypeScript errors such as "Cannot find name 'defineNitroPlugin'". The test files in the playground demonstrate that the fix enables server plugins within layers to be properly recognised by TypeScript configuration.
Out of Scope Changes Check ✅ Passed The pull request includes the core fix in packages/nitro-server/src/index.ts, which directly addresses the issue requirement, along with test files in the playground directory to verify the fix works correctly. The playground additions (test layer configuration, test server plugin, and main nuxt.config.ts modification) are reasonable test case additions to demonstrate that layer server files are now properly included in the TypeScript configuration. These test files support the verification of the fix but are not strictly required by the issue specification, though they are acceptable as a means of validating the implementation.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 15, 2025

Open in StackBlitz

@nuxt/kit

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: 758d7e1

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 15, 2025

CodSpeed Performance Report

Merging #33489 will not alter performance

Comparing dheeraj3587:main (758d7e1) with main (7bcc4ca)

Summary

✅ 10 untouched

@danielroe
Copy link
Member

the description of this PR does not match its contents

am I missing something?

Fixes #33477

Layer server directories were not being included in the generated
.nuxt/tsconfig.server.json, causing TypeScript errors in IDEs for
server files within layers (e.g., 'Cannot find name defineNitroPlugin').

This change adds layer server paths to the TypeScript configuration,
mirroring how Nitro already handles layer server directories in its
scanDirs configuration.

- Add layer server paths to tsconfig include array
- Ensures IDE TypeScript support for layer server files
- Removes need for manual workaround in nuxt.config.ts
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: 0

🧹 Nitpick comments (1)
packages/nitro-server/src/index.ts (1)

217-217: tsconfig.server.json: Windows compatibility OK, add explicit node_modules exclusion

  • join from pathe + relativeWithDot emit POSIX paths, so the **/* glob works on Windows.
  • Specifying exclude overrides TS’s default node_modules filter—nested node_modules under layer server dirs would be picked up if present. Consider adding a generic **/node_modules/** exclusion (e.g. via relativeWithDot(nuxt.options.buildDir, join(dirs.server, 'node_modules', '**/*'))).
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43db66d and a4090a8.

📒 Files selected for processing (4)
  • packages/nitro-server/src/index.ts (1 hunks)
  • playground/layers/test-layer/nuxt.config.ts (1 hunks)
  • playground/layers/test-layer/server/plugins/test.ts (1 hunks)
  • playground/nuxt.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • playground/layers/test-layer/nuxt.config.ts
  • playground/layers/test-layer/server/plugins/test.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

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

Follow standard TypeScript conventions and best practices

Files:

  • playground/nuxt.config.ts
  • packages/nitro-server/src/index.ts
⏰ 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: build
  • GitHub Check: code
🔇 Additional comments (1)
playground/nuxt.config.ts (1)

2-4: LGTM!

The test layer extension is correctly configured to verify the TypeScript configuration fix for layer server files.

@dheeraj3587
Copy link
Contributor Author

Hi @danielroe, thanks for the earlier feedback!

Apologies for the confusion in the previous commit. I’ve now updated the PR to include the actual fix in packages/nitro-server/src/index.ts, which adds layer server directories to the TypeScript include array for proper IDE support.

The playground layer files in playground/layers/test-layer/ remain to verify the fix works correctly.

The PR title and description now match the changes. Please let me know if any further adjustments are needed.

@danielroe
Copy link
Member

would you revert the changes to the playground and write an assertion in one of the other test suites that has layers? 🙏

we could do basic.test.ts but I think there's a fixture which is more unjt-test level and I'd prefer that if possible.

@danielroe
Copy link
Member

do you need any help?

dheeraj3587 added a commit to dheeraj3587/nuxt that referenced this pull request Oct 18, 2025
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
@dheeraj3587
Copy link
Contributor Author

Thank you! I’ve submitted PR #33510 (fix(nitro): include layer server directories in tsconfig.server.json). Happy to update it if you have any feedback. 🙌

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.

[bug] Layer server files not included in .nuxt/tsconfig.server.json in Nuxt 4.1.3

2 participants