fix: resolve client bundle collections from rootDir/workspaceDir#502
Conversation
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`.
commit: |
|
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 (3)
📝 WalkthroughWalkthroughsrc/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)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
did you check #501 - does that overlap at all? |
|
Yes I did and I don't think it overlaps, mine is related to client bundle 🤔 |
📚 Description
The client-bundle loader resolved
@iconify-json/*collections fromprocess.cwd(), so collections installed in a subproject'snode_moduleswere not found when the command was launched from a workspace root (e.g. runningnuxt devfrom a pnpm workspace root while@iconify-json/lucidelives inplaygrounds/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
discoverInstalledCollectionsby resolving from[rootDir, workspaceDir]. The client-bundle loader insrc/context.tswas the one spot it didn't cover.This resolves collections from
nuxt.options.rootDir, falling back toworkspaceDir(sinceloadCollectionFromFSaccepts a singlecwdand caches by it), reusing the now-exportedgetResolvePaths(nuxt)helper.Test
Added
test/client-bundle.test.tscovering both therootDirresolution and theworkspaceDirfallback. The collection is installed into a tempnode_modules(committing undernode_modulesisn't possible — it's git-ignored) whileprocess.cwd()is elsewhere, mimicking a workspace-root launch. Both cases fail before this change and pass after.