feat(vue): support experimental.componentDetection - #6731
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe changes document 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
|
@codspeedbot retry |
Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot. |
🔗 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 shipped the theme CSS of every component even if the app used one.Detection runs in the plugin's
confighook and the unused components' theme files are written with every class blanked, reusing thetheme.unstyledmachinery. Blanking now also covers base-shaped themes (a top-levelbasestring, e.g. Skeleton), whichapplyUnstyledused to miss, the same hole affectedtheme.unstyledon v4, andapplyUnstyledno longer mutates the shared theme objects it blanks. The files still exist with their variant declarations intact, so the#build/uitsconfig aliases,components.d.tsprop types and direct imports keep working, they just contribute no CSS. Stays opt-in in v4.Narrowing the emitted
@sourcelist instead doesn't work: the templates live innode_modules/.nuxt-ui, where Tailwind widens a file@sourceto a scan of its whole parent directory, so@source "./ui/button.ts";compiles byte-identical CSS to@source "./ui";. Blanking the files sidesteps that without any extra directive, andui.cssstays the same with detection on or off. The Nuxt integration is untouched, it narrows its@sourcelist in.nuxtwhere this widening doesn't apply.Measured on
nuxt-ui-templates/starter-vue(29 components detected):test/utils/components.spec.tsunit tests the detection and dependency resolution.Important
Two things for review: the doc badge is a placeholder
Soon, 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