-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
feat(kit,nuxt,schema): separate ts projects for node/app/nitro #30665
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
Conversation
|
WalkthroughThe changes introduce a comprehensive update to Nuxt's TypeScript configuration system. The core logic now generates multiple TypeScript configuration files for different contexts: 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 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 (5)
✨ Finishing Touches
🧪 Generate Unit Tests
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
🔭 Outside diff range comments (1)
test/bundle.test.ts (1)
Line range hint
41-130
: Blocking: Complete build output regressionThe test changes suggest that both client and server bundles are completely empty. This appears to be a critical regression possibly related to the tsconfig.server.json modifications. These changes would render the application non-functional as:
- No client-side JavaScript would be served to browsers
- No server-side code would be available for SSR
Please revert these test changes and investigate why the build process is failing to generate any output.
Consider adding pre-merge checks to ensure that builds always generate the expected minimal set of client and server files.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
test/bundle.test.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: codeql (javascript-typescript)
- GitHub Check: build
- GitHub Check: code
🔇 Additional comments (1)
test/bundle.test.ts (1)
121-121
:⚠️ Potential issueCritical: Server bundle is completely missing
The changes indicate that the server bundle and its dependencies are entirely absent (0.0k with no packages). This is a critical issue as a Nuxt application cannot function without server-side code.
Let's verify the server-side build state:
Also applies to: 124-124, 130-130
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
tsconfig.server.json
optionstsconfig.server.json
options
we might need a hook for nitro like also, I'm thinking of moving to this pattern for the tsconfig: https://github.com/danielroe/roe.dev/blob/main/tsconfig.json which would allow a single pass for type checking rather than multiple calls (and means we only need one |
CodSpeed Performance ReportMerging #30665 will not alter performanceComparing Summary
|
tsconfig.server.json
optionsThere 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
🧹 Nitpick comments (1)
docs/2.guide/1.concepts/8.typescript.md (1)
81-81
: Fix loose punctuation marks in documentation.The static analysis correctly identified loose punctuation marks that should be tightened.
Apply this diff to fix the punctuation:
-In case you need to extend options further, you can use the [`alias` property](/docs/api/nuxt-config#alias) within your `nuxt.config`. Nuxt will pick them up and extend the generated TypeScript configurations accordingly. -:: +In case you need to extend options further, you can use the [`alias` property](/docs/api/nuxt-config#alias) within your `nuxt.config`. Nuxt will pick them up and extend the generated TypeScript configurations accordingly.::-- **Clearer dependency management**: Each project explicitly declares its dependencies +- **Clearer dependency management**: Each project explicitly declares its dependencies.-::note -The project reference setup is handled automatically by Nuxt. You typically don't need to modify these configurations manually, but understanding how they work can help you troubleshoot type-checking issues. -:: +::note +The project reference setup is handled automatically by Nuxt. You typically don't need to modify these configurations manually, but understanding how they work can help you troubleshoot type-checking issues.::Also applies to: 105-105, 107-107
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package.json
is excluded by!package.json
,!**/package.json
📒 Files selected for processing (12)
docs/1.getting-started/18.upgrade.md
(1 hunks)docs/2.guide/1.concepts/8.typescript.md
(2 hunks)docs/2.guide/2.directory-structure/1.server.md
(0 hunks)docs/2.guide/2.directory-structure/3.tsconfig.md
(1 hunks)docs/3.api/5.kit/6.context.md
(1 hunks)docs/3.api/6.advanced/1.hooks.md
(1 hunks)docs/3.api/6.nuxt-config.md
(2 hunks)docs/6.bridge/2.typescript.md
(1 hunks)docs/7.migration/2.configuration.md
(1 hunks)packages/kit/src/template.ts
(7 hunks)packages/nuxt/src/app/index.ts
(1 hunks)packages/nuxt/src/app/types/augments.d.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- docs/2.guide/2.directory-structure/1.server.md
✅ Files skipped from review due to trivial changes (4)
- packages/nuxt/src/app/index.ts
- docs/2.guide/2.directory-structure/3.tsconfig.md
- docs/3.api/6.advanced/1.hooks.md
- docs/1.getting-started/18.upgrade.md
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.ts`: Follow standard TypeScript conventions and best practices
**/*.ts
: Follow standard TypeScript conventions and best practices
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)
List of files the instruction was applied to:
packages/nuxt/src/app/types/augments.d.ts
packages/kit/src/template.ts
🪛 LanguageTool
docs/2.guide/1.concepts/8.typescript.md
[uncategorized] ~81-~81: Loose punctuation mark.
Context: ... TypeScript configurations accordingly. :: ## Project References Nuxt uses [Typ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~105-~105: Loose punctuation mark.
Context: ...t explicitly declares its dependencies ::note The project reference setup is han...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~107-~107: Loose punctuation mark.
Context: ... you troubleshoot type-checking issues. :: ## Strict Checks TypeScript comes wi...
(UNLIKELY_OPENING_PUNCTUATION)
docs/3.api/6.nuxt-config.md
[uncategorized] ~35-~35: Loose punctuation mark.
Context: ...pt.tsConfigproperty in
nuxt.config`. :: Example: ```js export default { ...
(UNLIKELY_OPENING_PUNCTUATION)
docs/6.bridge/2.typescript.md
[uncategorized] ~40-~40: Loose punctuation mark.
Context: ...rectly extending .nuxt/tsconfig.json
. :: ::note Keep in mind that all options ...
(UNLIKELY_OPENING_PUNCTUATION)
🔇 Additional comments (16)
docs/6.bridge/2.typescript.md (1)
39-40
: Good documentation enhancement for the new TypeScript approach.The recommendation to use TypeScript project references aligns well with the broader changes in this PR that separate TypeScript configurations for different contexts.
docs/3.api/5.kit/6.context.md (1)
131-131
: Correct module name in TypeScript declaration.The change from
@nuxt/schema
tonuxt/schema
aligns the module augmentation with the correct module identifier used throughout the codebase.docs/7.migration/2.configuration.md (2)
159-170
: Correctly documents the new TypeScript project references approach.The migration from extending a single
.nuxt/tsconfig.json
to using TypeScript project references with multiple specialized configuration files (app, server, node) properly reflects the new architecture introduced in this PR.
174-174
: Appropriately generalises the command description.The updated description correctly reflects that multiple TypeScript configuration files are now generated rather than a single one.
packages/nuxt/src/app/types/augments.d.ts (2)
6-31
: Well-structured module augmentations for Nitro integration.The module augmentations for both
nitropack
andnitropack/types
are correctly implemented with appropriate interface definitions. The duplication ensures compatibility across different import patterns, and the interface properties align with Nitro's runtime configuration needs.
4-4
: ```shell
#!/bin/bashBroad search for dist/index.js anywhere in the repo
find . -type f -path "*/dist/index.js"
List any 'dist' directories under packages/nuxt to verify structure
find packages/nuxt -type d -name dist
</details> <details> <summary>docs/3.api/6.nuxt-config.md (2)</summary> `34-35`: **Correctly updates documentation for new TypeScript configuration approach.** The addition of the case-police-ignore comment and the updated note properly reflect the new multi-file TypeScript configuration system introduced in this PR. --- `60-64`: **Proper correction of section header and description.** The change from 'TSConfig' to 'tsConfig' correctly matches the actual property name in the configuration, and the updated description accurately reflects the multiple TypeScript configuration files now generated. </details> <details> <summary>docs/2.guide/1.concepts/8.typescript.md (2)</summary> `58-58`: **Documentation correctly reflects the new tsconfig structure.** The change from `.nuxt/tsconfig.json` to `.nuxt/tsconfig.app.json` aligns with the PR's objective of separating TypeScript projects. --- `77-82`: **Well-documented backward compatibility and migration path.** The note clearly explains the legacy support and provides guidance on the recommended approach with project references. </details> <details> <summary>packages/kit/src/template.ts (6)</summary> `71-71`: **Good addition of node context support.** The optional `node` parameter enables proper type generation for Node.js environments, aligning with the PR's goal of separating TypeScript projects. --- `86-90`: **Correct implementation of nodeReferences hook.** The conditional logic properly adds type references to the node context when specified. --- `154-175`: **Well-structured path resolution for different contexts.** The `resolveLayerPaths` function clearly separates paths for nuxt, nitro, and node contexts. The patterns correctly identify runtime code, server code, and configuration files. --- `189-192`: **Verify workspace inclusion logic for all contexts.** The workspace directory is only added to `include` and `legacyInclude` but not to `nodeInclude`. This might be intentional, but please verify if node context should also include workspace files. Could you confirm whether the node context should include workspace files when `typescript.includeWorkspace` is enabled? --- `278-312`: **Comprehensive TypeScript configuration for Node context.** The `nodeTsConfig` properly configures strict TypeScript settings for the Node.js environment. The use of `satisfies TSConfig` ensures type safety. --- `495-501`: **Efficient concurrent file writing implementation.** Good use of `Promise.all` to write all TypeScript configuration files concurrently, improving performance. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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: 0
🧹 Nitpick comments (1)
packages/nuxt/src/app/types/augments.ts (1)
6-31
: Consider reducing code duplication in module augmentations.The module augmentations are correctly implemented with proper TypeScript syntax and good deprecation documentation. However, the identical interfaces are duplicated between
nitropack
andnitropack/types
modules.Consider extracting the common interfaces to reduce duplication:
+interface NitroRuntimeConfigAppBase { + buildAssetsDir: string + cdnURL: string +} + +interface NitroRouteRulesBase { + ssr?: boolean + noScripts?: boolean + /** @deprecated Use `noScripts` instead */ + experimentalNoScripts?: boolean + appMiddleware?: Record<string, boolean> +} + declare module 'nitropack' { - interface NitroRuntimeConfigApp { - buildAssetsDir: string - cdnURL: string - } - interface NitroRouteRules { - ssr?: boolean - noScripts?: boolean - /** @deprecated Use `noScripts` instead */ - experimentalNoScripts?: boolean - appMiddleware?: Record<string, boolean> - } + interface NitroRuntimeConfigApp extends NitroRuntimeConfigAppBase {} + interface NitroRouteRules extends NitroRouteRulesBase {} } declare module 'nitropack/types' { - interface NitroRuntimeConfigApp { - buildAssetsDir: string - cdnURL: string - } - interface NitroRouteRules { - ssr?: boolean - noScripts?: boolean - /** @deprecated Use `noScripts` instead */ - experimentalNoScripts?: boolean - appMiddleware?: Record<string, boolean> - } + interface NitroRuntimeConfigApp extends NitroRuntimeConfigAppBase {} + interface NitroRouteRules extends NitroRouteRulesBase {} }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
package.json
is excluded by!package.json
,!**/package.json
packages/kit/package.json
is excluded by!**/package.json
packages/nuxt/package.json
is excluded by!**/package.json
packages/schema/package.json
is excluded by!**/package.json
packages/vite/package.json
is excluded by!**/package.json
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
,!pnpm-lock.yaml
📒 Files selected for processing (1)
packages/nuxt/src/app/types/augments.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.ts`: Follow standard TypeScript conventions and best practices
**/*.ts
: Follow standard TypeScript conventions and best practices
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)
List of files the instruction was applied to:
packages/nuxt/src/app/types/augments.ts
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: build
- GitHub Check: codeql (javascript-typescript)
- GitHub Check: codeql (actions)
- GitHub Check: lint-docs
- GitHub Check: docs
- GitHub Check: code
- GitHub Check: link-checker
🔇 Additional comments (4)
packages/nuxt/src/app/types/augments.ts (4)
2-2
: Good modernisation of import statement.Removing the explicit
.js
extension follows TypeScript best practices for module imports.
34-34
: Appropriate use of ESLint disable.The targeted ESLint disable for
@typescript-eslint/no-namespace
is appropriate here since global namespace augmentation is an intentional and valid TypeScript pattern.
50-56
: Good improvement to interface clarity.Explicitly declaring the ImportMeta properties instead of extending from another interface improves type clarity and supports the project's goal of better TypeScript project separation.
4-4
: Verify the dist export dependency.Exporting from
../../../dist/index
creates a dependency on compiled output which could cause build issues if the dist directory doesn't exist or is out of sync. Consider whether this barrel export is necessary or if it should reference source files instead.#!/bin/bash # Verify the dist export path and check for potential circular dependencies echo "Checking if the dist export path exists and what it contains..." fd -t f "index" packages/nuxt/dist/ 2>/dev/null || echo "dist/index not found" echo "" echo "Checking for potential circular imports involving this file..." rg -A 3 -B 3 "app/types/augments" packages/nuxt/src/
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 (1)
packages/nuxt/src/core/schema.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.ts`: Follow standard TypeScript conventions and best practices
**/*.ts
: Follow standard TypeScript conventions and best practices
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)
List of files the instruction was applied to:
packages/nuxt/src/core/schema.ts
⏰ Context from checks skipped due to timeout of 90000ms (16)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-off, json, 20)
- GitHub Check: test-fixtures (windows-latest, built, rspack, default, manifest-on, json, 20)
- GitHub Check: test-fixtures (windows-latest, dev, vite, default, manifest-off, json, 20)
- GitHub Check: test-fixtures (windows-latest, dev, vite, default, manifest-on, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-off, json, 20)
- GitHub Check: test-fixtures (windows-latest, dev, vite, async, 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-on, js, 20)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-on, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, built, webpack, async, manifest-on, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-on, json, 20)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, js, 20)
- GitHub Check: typecheck (windows-latest, bundler)
- GitHub Check: typecheck (ubuntu-latest, bundler)
- GitHub Check: test-benchmark
🔇 Additional comments (1)
packages/nuxt/src/core/schema.ts (1)
35-35
: LGTM! Proper node environment support added.The addition of the schema reference to
nodeReferences
aligns with the multi-config TypeScript approach, ensuring schema types are available in the node environment alongside the standard references.
…30665) Co-authored-by: Daniel Roe <daniel@roe.dev>
🔗 Linked issue
nuxi typecheck
cli#323vue-tsc
overwrite server imports with app imports #29263resolves #31989
resolves #32343
resolves #22572
📚 Description
Not sure but I can imagine these changes may break other functionality.
skipLibCheck
needs to be enabled to get around type errors whentsconfig.server.json
is used for typecheck.* Removes./types/nitro.d.ts
fromnuxt.d.ts
since that bypasses theexclude
entries by having explicit imports to server files (Run typecheck for client *and* server withnuxi typecheck
cli#323 (comment)).tsconfig.server.json
has an../**/*
entry in theinclude
array, having this adds will also include client files, this is added based on Nitro'srootDir
, so as a hack/workaround I assign therootDir
tosrcDir
(which I think is theserverDir
) which replaces/removes the entry.Okay I think I'm starting to understand the underlying issue.
The
nitro.d.ts
reference is required to have types for nitro routes/endpoints from within the app/client code, this causes issues when those types rely on different aliases/imports/types isolated to the nitro typescript config (as it does in #29263). This is also the source of the nitro auto import autocompletion in app/client code.