Skip to content

feat: pre-bundle used icons into @nuxt/icon client bundle#6633

Draft
benjamincanac wants to merge 2 commits into
v4from
feat/pre-bundle-icons
Draft

feat: pre-bundle used icons into @nuxt/icon client bundle#6633
benjamincanac wants to merge 2 commits into
v4from
feat/pre-bundle-icons

Conversation

@benjamincanac

Copy link
Copy Markdown
Member

🔗 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's clientBundle.scan can't discover them and they end up fetched at runtime, causing a flash on first paint.

This hooks into icon:clientBundleIcons and adds those icons to the client bundle so they're embedded at build time. The icons come from the resolved app.config.ui.icons, so overrides that stay within a shipped collection are picked up too.

To stay safe, an icon is only added when its collection data is actually installed, resolved from rootDir/workspaceDir to match how @nuxt/icon loads it. Anything it can't find is left to runtime loading rather than failing the build, and the lookup hits the filesystem directly so it stays correct under the dev stub too.

Important

This depends on nuxt/icon#502, which makes the client bundle resolve collections from rootDir/workspaceDir instead of process.cwd() (without it, monorepo/workspace builds break). It currently points at the pkg.pr.new build of that PR, so this stays a draft until #502 is released and the dependency is bumped to a normal version.

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.
@github-actions github-actions Bot added the v4 #4488 label Jun 25, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 25, 2026

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

commit: 946c21e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-bundle used icons

1 participant