fix(bundle): include custom collection aliases in the client bundle - #536
fix(bundle): include custom collection aliases in the client bundle#536giaBaoJS wants to merge 1 commit into
Conversation
`includeCustomCollections` walked only `collection.icons`, so an alias declared in a custom `IconifyJSON` collection never reached the client bundle, while the server bundle (which ships the whole collection JSON) and an explicitly listed `clientBundle.icons` entry both resolve it.
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughWhen Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Custom client bundles now include aliases declared by enabled custom icon collections, including inherited icon data and flip transforms. The targeted behavior is covered, with no remaining current-head merge risk identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
src/core/bundle.tsParsing error: Unexpected token { test/bundle.test.tsParsing error: Unexpected token { 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 |
Bug
An alias declared in a custom
IconifyJSONcollection is missing from the client bundle whenclientBundle.includeCustomCollectionsis on (its default whenprovideris notserver). Rendering<Icon name="paid-icons:house" />then falls back to runtime loading, and withprovider: 'none'it never renders at all.Reproduction
.nuxt/nuxt-icon-client-bundle.mjscontainspaid-icons:homebut notpaid-icons:house.Root cause
resolveBundleIconswalks onlyObject.keys(collection.icons)when bundling a whole custom collection, and anIconifyJSONkeeps aliases in a separatealiasesmap. The two sibling paths already handle them: the server bundle serializes the entire collection JSON andgetIconsresolves the alias at request time, and an alias listed explicitly inclientBundle.iconsgoes throughgetIconData, which follows the alias tree. Only the whole-collection path skipped them.The fix walks
collection.aliasesas well and resolves each name through the samegetIconDatacall, so an alias lands in the bundle as a normal icon with its parent body and its own transforms.Test
test/bundle.test.tsgainsbundles the aliases of a custom collection: a collection with one icon and two aliases (a plain one and anhFlipone) must produce all three names, the alias must carry the parent body, and the flipped alias must keephFlip: true. Without the change it fails withexpected [ 'home' ] to deeply equal [ 'home', 'home-flip', 'house' ].