feat(vue): support experimental.componentDetection#6731
Conversation
📝 WalkthroughWalkthroughThe changes add Vue component detection configuration documentation, thread Vue root and component directory information through template generation, and generate source directives from detected components. Extra scan directories now support packages, external component directories, and nested path handling. Component detection ignores nested Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
commit: |
experimental.componentDetection
🔗 Linked issue
Relates to #6296
❓ Type of change
📚 Description
Ports
experimental.componentDetectionto the Vue (unplugin) integration. It already exists for Nuxt, but the Vue build always emitted@source "./ui", so Tailwind scanned all ~163 generated theme files and every app shipped CSS for every component even if it used one.With detection enabled, the plugin scans the Vite root for used components and narrows the emitted
@sourcelines to just those components and their dependencies. In an isolated single-UButtonapp this cuts the theme CSS from 179 KB to 45 KB (75%). Stays opt-in in v4.The shared
generateSourceschange keeps the Nuxt output byte-identical (layer and inline sources stay Nuxt-only, the detection branch is equivalent). Full suite passes with zero snapshot changes, and a newtest/utils/component-detection.spec.tscovers the narrowing, the disabled default, and the empty-detection fallback.Stacked on #6730.
Important
Two things for review: the doc badge is a placeholder
4.10+, please set it to the real target release. And newly used components are only picked up on the next dev-server start (documented as a restart note); live HMR re-detection is left as a follow-up.📝 Checklist