Skip to content

perf(types): decouple useComponentProps from the component-types barrel#6648

Merged
benjamincanac merged 2 commits into
v4from
perf/decouple-theme-types
Jun 29, 2026
Merged

perf(types): decouple useComponentProps from the component-types barrel#6648
benjamincanac merged 2 commits into
v4from
perf/decouple-theme-types

Conversation

@sandros94

Copy link
Copy Markdown
Member

🔗 Linked issue

Follow up from #6647

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This one is also performance optimization only related to the development of Nuxt UI itself. By widening useComponentProps's internal injection we reach the same level of module graph performance as per a downstream library using a built version of Nuxt UI.

What this means in practice is that restarting Volar or the IDE while developing or testing anything in the playgrounds would result in ~2x faster cold starts and incremental evaluations.

What is not affected are CIs and anything related to UTheme, since both need to load every component anyway. While downstream performance have been mainly covered in #6646

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@sandros94 sandros94 self-assigned this Jun 28, 2026
@sandros94
sandros94 requested a review from benjamincanac as a code owner June 28, 2026 16:04
@sandros94 sandros94 added enhancement New feature or request v4 #4488 p3-low Minor cosmetic, edge case, or documentation issue labels Jun 28, 2026
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2c9e1c8e-3f13-4994-baf8-29a6944ed2a4

📥 Commits

Reviewing files that changed from the base of the PR and between ab54d44 and 2d4975b.

📒 Files selected for processing (1)
  • src/runtime/types/index.ts

📝 Walkthrough

Walkthrough

Three theme-related types (ThemeUI, ThemeDefaults, ThemeContextDefaults) and a helper (ThemeSlotOverrides) are moved out of src/runtime/composables/useComponentProps.ts into a new dedicated file src/runtime/types/theme.ts. The new file is re-exported via src/runtime/types/index.ts. Import sites in Theme.vue and the test spec are updated accordingly. useComponentProps.ts removes the now-redundant type exports and simplifies ThemeContext.defaults to ComputedRef<Record<string, Record<string, any> | undefined>>. The ESLint config replaces a per-file exemption with a broader no-restricted-imports rule covering all components and composables.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: decoupling useComponentProps from the component-types barrel.
Description check ✅ Passed The description is clearly related to the performance-oriented type-surface cleanup in this changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/decouple-theme-types

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/composables/useComponentProps.spec.ts (1)

3-3: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Import ThemeDefaults through the public composables barrel.

This spec now bypasses src/runtime/composables/index.ts, so a broken re-export there would go unnoticed. Importing from the barrel keeps the test aligned with the public API this PR adds.

Suggested change
-import type { ThemeDefaults } from '../../src/runtime/types/theme'
+import type { ThemeDefaults } from '../../src/runtime/composables'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/composables/useComponentProps.spec.ts` at line 3, The spec currently
imports ThemeDefaults directly from the runtime types path, which bypasses the
public composables barrel and won’t catch a broken re-export. Update the import
in useComponentProps.spec.ts to come through the composables index barrel so the
test exercises the public API exposed by src/runtime/composables/index.ts. Keep
the test using ThemeDefaults, but reference it via the barrel export to match
the intended integration point.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/composables/useComponentProps.spec.ts`:
- Line 3: The spec currently imports ThemeDefaults directly from the runtime
types path, which bypasses the public composables barrel and won’t catch a
broken re-export. Update the import in useComponentProps.spec.ts to come through
the composables index barrel so the test exercises the public API exposed by
src/runtime/composables/index.ts. Keep the test using ThemeDefaults, but
reference it via the barrel export to match the intended integration point.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 74d49259-ee09-4b66-a3fa-e7ec7cf19d59

📥 Commits

Reviewing files that changed from the base of the PR and between 3bf1a92 and ab54d44.

📒 Files selected for processing (6)
  • eslint.config.mjs
  • src/runtime/components/Theme.vue
  • src/runtime/composables/index.ts
  • src/runtime/composables/useComponentProps.ts
  • src/runtime/types/theme.ts
  • test/composables/useComponentProps.spec.ts
💤 Files with no reviewable changes (1)
  • eslint.config.mjs

@pkg-pr-new

pkg-pr-new Bot commented Jun 28, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/ui@6648

commit: 2d4975b

@benjamincanac benjamincanac removed enhancement New feature or request p3-low Minor cosmetic, edge case, or documentation issue labels Jun 29, 2026
Move ThemeDefaults/ThemeUI/ThemeContextDefaults re-export to types/index.ts where the rest of the type surface lives, instead of composables/index.ts.
@benjamincanac
benjamincanac merged commit 6576fb8 into v4 Jun 29, 2026
24 checks passed
@benjamincanac
benjamincanac deleted the perf/decouple-theme-types branch June 29, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants