Skip to content

fix: don't hard-fail on unresolvable hook-contributed client bundle icons#504

Merged
atinux merged 2 commits into
mainfrom
fix/client-bundle-hook-icons-best-effort
Jun 29, 2026
Merged

fix: don't hard-fail on unresolvable hook-contributed client bundle icons#504
atinux merged 2 commits into
mainfrom
fix/client-bundle-hook-icons-best-effort

Conversation

@benjamincanac

@benjamincanac benjamincanac commented Jun 29, 2026

Copy link
Copy Markdown
Member

📚 Description

Icons contributed by modules through the icon:clientBundleIcons hook hard-failed the build when they couldn't be resolved, even though scanned icons in the same situation already fall back to runtime loading.

Now only icons explicitly listed in clientBundle.icons hard-fail. Scanned and hook-contributed icons are best-effort; unresolvable hook icons are warned about rather than thrown.

This unblocks nuxt/ui#6633, which can now drop its filesystem collection-presence check and rely on @nuxt/icon to skip whatever it can't resolve.

Test

Extended test/client-bundle.test.ts: a hook-contributed icon whose collection/name can't be resolved is omitted rather than throwing, while an unresolvable icon in clientBundle.icons still fails the build.

…cons

Icons contributed by modules through the `icon:clientBundleIcons` hook were
treated as hard build failures when they couldn't be resolved (collection not
installed, or a name that doesn't exist / is version-skewed), even though
scanned icons in the exact same situation already fall back to runtime loading.

Only icons the user explicitly listed in `clientBundle.icons` now hard-fail the
build. Scanned and hook-contributed icons are best-effort: dropped from the
bundle and resolved at runtime instead. Hook-contributed icons are collected
separately and warned about (without throwing), since - unlike scanned icons -
they aren't subject to extraction false positives.
@pkg-pr-new

pkg-pr-new Bot commented Jun 29, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/nuxt/icon/@nuxt/icon@504

commit: b46d8f8

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

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: c67899b0-6e41-45c1-ae55-3e16af72719e

📥 Commits

Reviewing files that changed from the base of the PR and between 813b90f and b46d8f8.

📒 Files selected for processing (1)
  • src/context.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/context.ts

📝 Walkthrough

Walkthrough

loadClientBundleCollections in src/context.ts now returns a dropped: string[] field. Unresolved icons that were not explicitly requested are added to dropped, while explicitly configured icons that fail to resolve still go to failed. All return paths include dropped. In src/bundle-client.ts, dropped is destructured from the result and a warning is emitted when it is non-empty. Tests in test/client-bundle.test.ts add a hookIcons parameter to the harness and cover the distinct resolution outcomes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: hook-contributed client bundle icons no longer hard-fail when unresolved.
Description check ✅ Passed The description matches the changeset and explains the new best-effort handling plus the added test coverage.
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 fix/client-bundle-hook-icons-best-effort

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

Choose a reason for hiding this comment

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

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 `@src/context.ts`:
- Around line 244-255: The icon resolution loop in the bundle-building logic
still treats hook-contributed icons as fatal when an exception is thrown after
the `!data` branch. Update the `catch` path to mirror the existing best-effort
handling: only add explicitly user-listed icons to `failed`, and route
hook-contributed or scanned icons to `dropped` so they fall back to runtime
loading. Keep the same `userIcons.has(icon)` and `this.scannedIcons.has(icon)`
checks consistent between the success and exception paths.
🪄 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: e6795ac0-d3a9-4ec7-a719-37e9d4e28cf5

📥 Commits

Reviewing files that changed from the base of the PR and between 23ef020 and 813b90f.

📒 Files selected for processing (3)
  • src/bundle-client.ts
  • src/context.ts
  • test/client-bundle.test.ts

Comment thread src/context.ts
The icon resolution loop's catch block unconditionally pushed to `failed`, so an
exception thrown during resolution (e.g. `loadCollectionFromFS` rejecting on a
corrupt/version-skewed `icons.json`) hard-failed the build even for scanned and
hook-contributed icons. Mirror the best-effort handling from the `!data` branch:
only explicit user icons hard-fail, scanned/hook icons fall back to runtime.
@atinux
atinux merged commit c4f7935 into main Jun 29, 2026
5 checks passed
@atinux
atinux deleted the fix/client-bundle-hook-icons-best-effort branch June 29, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants