Skip to content

Conversation

@8ctavio
Copy link
Contributor

@8ctavio 8ctavio commented Oct 2, 2025

🔗 Linked issue

Resolves #33374

📚 Description

  • Add new Component.declarationPath property
  • In resolveComponentTypes, retrieve module/component path from Component.declarationPath if provided, since it will be used to generate a type template.

@8ctavio 8ctavio requested a review from danielroe as a code owner October 2, 2025 19:40
@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 2, 2025

Walkthrough

  • Added an optional declarationPath?: string to the Component interface in packages/schema/src/types/components.ts to record a component declaration file path.
  • Updated resolveComponentTypes in packages/nuxt/src/components/templates.ts to use a local componentPath = c.declarationPath || c.filePath when constructing the typeof import type hint, replacing prior direct use of c.filePath.
  • Documentation updated to document declarationPath on AddComponentOptions in docs/3.api/5.kit/5.components.md.
  • No exported/public function signatures were otherwise changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The current title suggests only a documentation update for declarationPath in the addComponent API, whereas the pull request actually implements a new declarationPath property on the Component type, modifies resolveComponentTypes logic to use it, and updates associated schemas and documentation. This phrasing is too narrow and misleading because it fails to highlight the core feature addition in Nuxt itself. A clear summary of the functional change is needed. Please rename the title to clearly summarise the feature addition, for example “feat(nuxt): add Component.declarationPath property and update resolveComponentTypes and documentation”.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues Check ✅ Passed The changes fully implement the objectives of issue #33374 by introducing the optional declarationPath on the Component type and updating resolveComponentTypes to prefer this new field, matching the specified diff of `c.declarationPath
Out of Scope Changes Check ✅ Passed All modifications are directly related to introducing the declarationPath field, updating type resolution logic, and corresponding documentation, with no unrelated or extraneous changes present.
Description Check ✅ Passed The pull request description clearly explains the addition of the new Component.declarationPath property and its usage in resolveComponentTypes, directly reflecting the changes made without being generic or off-topic.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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 2, 2025

Open in StackBlitz

@nuxt/kit

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: 58cd078

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 2, 2025

CodSpeed Performance Report

Merging #33380 will not alter performance

Comparing 8ctavio:feat-1 (58cd078) with main (011c13e)

Summary

✅ 10 untouched

@danielroe
Copy link
Member

my apologies @8ctavio - I merged a duplicate PR not realising it wasn't yours (#33419).

I'll be merging this one as well though 🙏❤️

@danielroe danielroe changed the title feat(nuxt): add declarationPath property for Component declaration file paths docs: update declarationPath in addComponent Oct 7, 2025
@danielroe danielroe merged commit 31af68b into nuxt:main Oct 7, 2025
8 of 9 checks passed
@github-actions github-actions bot mentioned this pull request Oct 7, 2025
@8ctavio
Copy link
Contributor Author

8ctavio commented Oct 7, 2025

@danielroe don't worry 👍. Thank you.

About the other PR though, I see that it added declarationPath support for scanning dirs with addComponentsDirs as well, but I'm not sure the expected behavior is implemented:

This line assigns dir.declarationPath to a component's declarationPath if present; I think there are two problems with this:

  1. For consistency, I suppose ScanDir.declarationPath should be a directory path, but Component.declarationPath expects a file path.
  2. If dir.declarationPath is a file path, all scanned components would try to get their declaration from dir.declarationPath, which is not invalid, but it seems that the default behavior should rather be to join dir.declarationPath with found file names on dir.path:
- declarationPath: dir.declarationPath || filePath,
+ declarationPath: join(dir.declarationPath, _file) || filePath

If dir.declarationPath as a file path should be supported, it could be checked whether dir.declarationPath is a file or directory, but ensure Component.declarationFile is a file path (or is not defined).

However, I have not encountered specific use cases for addComponentsDirs, so I can't say for sure that dir.declarationPath as a directory path is prefered.

@danielroe
Copy link
Member

you make a good point. we should probably not support it for component dirs directly.

@github-actions github-actions bot mentioned this pull request Oct 23, 2025
danielroe pushed a commit that referenced this pull request Oct 25, 2025
@github-actions github-actions bot mentioned this pull request Oct 25, 2025
@8ctavio 8ctavio deleted the feat-1 branch October 25, 2025 19:36
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.

Add Component property to support alternative path for components' declaration files

2 participants