-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat(nuxt): allow specifying component declarationPath
#33419
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(nuxt): allow specifying component declarationPath
#33419
Conversation
…le paths - Add declarationPath to Component and ScanDir/ComponentsDir interfaces - Update scanComponents to handle declarationPath from directory config - Update type template generation to use declarationPath when available - Maintain backward compatibility with filePath fallback - Resolves nuxt#33374
|
|
WalkthroughAdds an optional Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches❌ 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 |
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #33419 will not alter performanceComparing Summary
|
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 (2)
packages/nuxt/test/scan-components.test.ts (2)
89-241: Test expectations correctly updated to includedeclarationPathfield.The additions properly reflect the new
Componentinterface shape. EachdeclarationPathmatches the component file path, which correctly validates the default fallback behavior when no customdeclarationPathis configured.However, consider adding test coverage for the primary use case where
declarationPathdiffers fromfilePath. This would validate the feature's intended functionality per issue #33374.Add a test directory configuration with a custom
declarationPathto validate the feature:{ path: rFixture('components'), extensions: ['vue'], pattern: '**/*.{vue,}', ignore: ['**/*.stories.{js,ts,jsx,tsx}', '**/*{M,.m,-m}ixin.{js,ts,jsx,tsx}', '**/*.d.ts'], transpile: false, declarationPath: rFixture('types/custom-declarations.d.ts'), // Custom declaration path }Then verify that scanned components from this directory use the custom
declarationPathrather than theirfilePath.
247-253: Consider verifying bothfilePathanddeclarationPathtogether.The test deletes
filePathbefore comparison, which prevents verifying the relationship betweenfilePathanddeclarationPath. Since the PR introduces logic to fall back tofilePathwhendeclarationPathis not provided, consider asserting both properties to ensure the fallback behaviour works correctly.Alternatively, add a separate assertion to verify the relationship:
// Verify declarationPath defaults to filePath when not explicitly set for (const c of scannedComponents) { if (!dirs.find(d => d.declarationPath)) { expect(c.declarationPath).toBe(c.filePath) } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/nuxt/test/scan-components.test.ts(12 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/nuxt/test/scan-components.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/scan-components.test.ts
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/test/scan-components.test.ts (1)
86-241: Test data correctly updated for default behaviour.The
declarationPathfield has been properly added to all component entries, demonstrating the default fallback behaviour wheredeclarationPathequalsfilePath. The test coverage spans various component scenarios including islands, globals, and client/server modes.Consider adding a test case where
declarationPathdiffers fromfilePathto verify the core feature—using an explicit declaration path separate from the source file. This would ensure the feature works as intended when consumers actually specify a different declaration path.Example test configuration:
{ path: rFixture('components'), declarationPath: rFixture('types/components'), // ... other config }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/nuxt/src/components/scan.ts(1 hunks)packages/nuxt/src/components/templates.ts(1 hunks)packages/nuxt/test/scan-components.test.ts(11 hunks)packages/schema/src/types/components.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/nuxt/src/components/scan.ts
- packages/nuxt/src/components/templates.ts
🧰 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/nuxt/test/scan-components.test.tspackages/schema/src/types/components.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/scan-components.test.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). (3)
- GitHub Check: build
- GitHub Check: codeql (javascript-typescript)
- GitHub Check: code
🔇 Additional comments (3)
packages/schema/src/types/components.ts (2)
24-29: LGTM! Well-documented addition.The
declarationPathproperty is properly defined as optional with clear documentation. The@default filePathnotation effectively communicates the fallback behaviour.
75-79: Consistent and well-integrated addition.The
declarationPathproperty mirrors the Component interface addition, ensuring consistency across the type system. Since ComponentsDir extends ScanDir, it correctly inherits this property.packages/nuxt/test/scan-components.test.ts (1)
245-254: Testing approach correctly isolates the new property.The test appropriately removes
filePathfrom assertions whilst retainingdeclarationPath, allowing focused verification of the new property. The@ts-expect-errorsuppressions are justified with clear comments.
|
@danielroe Just a friendly reminder about this PR when you have a moment! All checks are passing and it's ready for your review. 😊 |
|
don't worry! I was waiting until we were ready for a minor/feature release. |
|
I really appreciate your review and guidance on this PR. I was wondering — since the repo participates in If that’s not possible at this stage, no worries at all — I completely understand and am happy to wait until the PR is merged. Thank you so much! 🙏 |
declarationPath
…le paths
Componentproperty to support alternative path for components' declaration files #33374🔗 Linked issue
📚 Description