Skip to content

Conversation

@KazariEX
Copy link
Member

@KazariEX KazariEX commented Oct 3, 2025

🔗 Linked issue

📚 Description

typeof import('...').default is a valid reference compared to typeof import('...')['default']. It is required to implement the secondary jump for Go to References.

Waiting for unjs/knitwork#125.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@KazariEX KazariEX changed the title refactor(nuxt): generate .default instead of ['default'] for component declarations refactor(nuxt): generate valid references for component declaration items Oct 3, 2025
@KazariEX KazariEX force-pushed the feat/components-property-access branch from bb56d29 to 80c687e Compare November 14, 2025 16:19
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 14, 2025

Open in StackBlitz

@nuxt/kit

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

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@33388

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: 80c687e

@KazariEX KazariEX marked this pull request as ready for review November 14, 2025 16:25
@KazariEX KazariEX requested a review from danielroe November 14, 2025 16:25
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 14, 2025

CodSpeed Performance Report

Merging #33388 will not alter performance

Comparing sinrabansyo:feat/components-property-access (80c687e) with main (243261e)1

Summary

✅ 10 untouched

Footnotes

  1. No successful run was found on main (98c2f13) during the generation of this report, so 243261e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

Walkthrough

The change modifies component type resolution in the Nuxt templates module by replacing a dynamically constructed string-based type expression with a direct function call. The genDynamicTypeImport function from knitwork is now imported and used in resolveComponentTypes to generate component types, replacing the previous approach that assembled typeof expressions with dynamic import wrappers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify the functional equivalence between the old typeof-based construction and the new genDynamicTypeImport approach
  • Assess the implications of the behavioural change for server and island component type interpretation
  • Confirm that the refactoring does not introduce unintended type inference or resolution differences

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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: refactoring component declaration generation to use valid property access syntax for better IDE support.
Description check ✅ Passed The description explains the technical rationale for the change, noting that the new syntax form is required for IDE "Go to References" functionality and references a dependency on unjs/knitwork#125.
✨ 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.

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98c2f13 and 80c687e.

⛔ Files ignored due to path filters (5)
  • packages/nuxt/package.json is excluded by !**/package.json
  • packages/rspack/package.json is excluded by !**/package.json
  • packages/vite/package.json is excluded by !**/package.json
  • packages/webpack/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/components/templates.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: huang-julien
Repo: nuxt/nuxt PR: 29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.
Learnt from: GalacticHypernova
Repo: nuxt/nuxt PR: 26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
📚 Learning: 2024-12-12T12:36:34.871Z
Learnt from: huang-julien
Repo: nuxt/nuxt PR: 29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.

Applied to files:

  • packages/nuxt/src/components/templates.ts
📚 Learning: 2024-11-05T15:22:54.759Z
Learnt from: GalacticHypernova
Repo: nuxt/nuxt PR: 26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.

Applied to files:

  • packages/nuxt/src/components/templates.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). (20)
  • GitHub Check: test-fixtures (windows-latest, built, vite, async, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, built, webpack, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, built, vite, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, built, vite-env-api, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, built, webpack, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, built, rspack, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, built, vite, default, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, built, vite-env-api, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite-env-api, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, async, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite-env-api, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, webpack, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, js, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, json, lts/-1)
  • GitHub Check: test-benchmark
🔇 Additional comments (1)
packages/nuxt/src/components/templates.ts (1)

122-124: The refactor looks correct, but verify edge cases with exports.

The change to use genDynamicTypeImport simplifies the type generation logic. However, ensure that:

  1. genDynamicTypeImport properly handles both default exports (c.export === 'default') and named exports
  2. The function handles cases where c.export might be undefined or empty
  3. The generated type format (typeof import('...').default) works correctly for all component scenarios

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you ❤️

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.

2 participants