Skip to content

fix: resolve client bundle collections from rootDir/workspaceDir#502

Merged
atinux merged 1 commit into
mainfrom
fix/client-bundle-resolve-paths
Jun 25, 2026
Merged

fix: resolve client bundle collections from rootDir/workspaceDir#502
atinux merged 1 commit into
mainfrom
fix/client-bundle-resolve-paths

Conversation

@benjamincanac

Copy link
Copy Markdown
Member

📚 Description

The client-bundle loader resolved @iconify-json/* collections from process.cwd(), so collections installed in a subproject's node_modules were not found when the command was launched from a workspace root (e.g. running nuxt dev from a pnpm workspace root while @iconify-json/lucide lives in playgrounds/app/node_modules). The build then failed with "Nuxt Icon could not fetch the icon data for client bundle".

#477 already fixed this class of bug for the server bundle and discoverInstalledCollections by resolving from [rootDir, workspaceDir]. The client-bundle loader in src/context.ts was the one spot it didn't cover.

This resolves collections from nuxt.options.rootDir, falling back to workspaceDir (since loadCollectionFromFS accepts a single cwd and caches by it), reusing the now-exported getResolvePaths(nuxt) helper.

Test

Added test/client-bundle.test.ts covering both the rootDir resolution and the workspaceDir fallback. The collection is installed into a temp node_modules (committing under node_modules isn't possible — it's git-ignored) while process.cwd() is elsewhere, mimicking a workspace-root launch. Both cases fail before this change and pass after.

The client-bundle loader resolved `@iconify-json/*` collections from `process.cwd()`, so collections installed in a subproject's node_modules were not found when the command was launched from a workspace root.

Resolve from `nuxt.options.rootDir` (falling back to `workspaceDir`) instead, mirroring #477 which fixed the same class of bug for the server bundle and `discoverInstalledCollections`.
@pkg-pr-new

pkg-pr-new Bot commented Jun 25, 2026

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

commit: 1de044f

@coderabbitai

coderabbitai Bot commented Jun 25, 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: ab3ea650-5884-4939-8cfc-215ea3d739e3

📥 Commits

Reviewing files that changed from the base of the PR and between 0d69f12 and 1de044f.

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

📝 Walkthrough

Walkthrough

src/collections.ts exports getResolvePaths. src/context.ts imports it and uses it in loadClientBundleCollections to resolve client-bundle collections from custom entries or from each directory returned by getResolvePaths(this.nuxt), passing an explicit cwd to loadCollectionFromFS. A new Vitest file adds temporary package helpers and covers resolution from rootDir and fallback to workspaceDir.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% 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: resolving client-bundle collections from rootDir with workspaceDir fallback.
Description check ✅ Passed The description matches the changeset and explains the bug fix, implementation, and tests for collection resolution.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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-resolve-paths

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.

@danielroe

Copy link
Copy Markdown
Member

did you check #501 - does that overlap at all?

@benjamincanac

Copy link
Copy Markdown
Member Author

Yes I did and I don't think it overlaps, mine is related to client bundle 🤔

@atinux
atinux merged commit a744c65 into main Jun 25, 2026
5 checks passed
@atinux
atinux deleted the fix/client-bundle-resolve-paths branch June 25, 2026 12:24
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.

3 participants