feat(module): pre-bundle used icons into @nuxt/icon client bundle#6633
Conversation
Add the icons Nuxt UI uses (chevrons, loading spinner, close, etc.) to `@nuxt/icon`'s client bundle via the `icon:clientBundleIcons` hook so they're embedded at build time instead of fetched at runtime, removing the first-paint flash. Icons are only added when their collection data is installed (resolved from `rootDir`/`workspaceDir` to match `@nuxt/icon`), so missing collections fall back to runtime loading instead of failing the build. Resolves #6295
Temporary: relies on nuxt/icon#502 (client bundle resolves collections from rootDir/workspaceDir). Revert to a normal version once it's released.
commit: |
@nuxt/icon client bundle@nuxt/icon client bundle
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughA new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@docs/content/docs/1.getting-started/6.integrations/1.icons/1.nuxt.md`:
- Around line 135-137: The note in the icons docs is too broad and should only
apply to overrides from untrusted or uninstalled collections, not all
app.config.ts icon overrides. Update the wording in the relevant docs note to
reflect that getClientBundleIcons in src/module.ts bundles overrides from
shipped collections like lucide, and direct users to clientBundle.icons only for
icons that are not already available locally.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 895150c9-f610-42d2-8c5b-8f7b21a6312f
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (6)
docs/content/docs/1.getting-started/6.integrations/1.icons/1.nuxt.mdpackage.jsonpnpm-workspace.yamlsrc/module.tssrc/utils/icons.tstest/utils/icons.spec.ts
🔗 Linked issue
Resolves #6295
📚 Description
Nuxt UI components rely on a fixed set of icons (chevrons, the loading spinner, close buttons, and so on) that live inside
node_modules, so@nuxt/icon'sclientBundle.scancan't discover them and they end up fetched at runtime, causing a flash on first paint.This hooks into
icon:clientBundleIconsand adds those icons to the client bundle so they're embedded at build time. The icons come from the resolvedapp.config.ui.icons, so overrides that stay within a shipped collection are picked up too.Names are restricted to the collections Nuxt UI ships its defaults in (currently
lucide) so multi-word collection names can't be mis-split. Anything@nuxt/iconstill can't resolve (collection not installed, icon name missing) is dropped and falls back to runtime loading instead of failing the build, so no availability check is needed on our side.Important
Requires
@nuxt/icon@>=2.2.5, which ships the two changes this relies on: nuxt/icon#502 (resolve the client bundle fromrootDir/workspaceDirinstead ofprocess.cwd(), so monorepo/workspace builds work) and nuxt/icon#504 (treat hook-contributed icons as best-effort, dropping unresolvable ones instead of throwing). The dependency has been bumped to^2.2.5.