perf(server-bundle): discover collections via directory listing#501
Conversation
`discoverInstalledCollections` probed all ~220 known collection names with
`isPackageExists('@iconify-json/<name>')`. Each *missing* name triggers a full
module resolution that walks `node_modules` up to the filesystem root, so on a
project with few/no `@iconify-json` packages this loop takes ~0.8–1.9s.
The server bundle is generated lazily on the first dev request, so that cost
lands on the cold first page load even when no icon is rendered (`server` is the
SSR-default provider). Measured ~862ms on a fresh app; switching the provider to
`iconify` (which skips this path) removed the same ~0.6s.
Instead, list the `@iconify-json` scope directory across `node_modules` (walking
up from each resolve path) once, validate each entry ships an `icons.json`, and
intersect with the known list — behaviour-equivalent, ~3ms. Yarn PnP (no
`node_modules` to read) falls back to the resolver probe.
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
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 |
🔗 Linked issue
nuxt/nuxt#35390
📚 Description
This PR rewrites
discoverInstalledCollectionsfor the typical (non-PnP) case. Now, it finds installed icon sets by listing the@iconify-jsonscope directory acrossnode_modulesinstead of resolving all ~220 known collection names one-by-one vialocal-pkg(this still happens in the PnP case).The old loop did a full module resolution per missing name, costing ~300-800ms that landed on the cold first dev request because the server bundle is generated lazily.
Local bench
discoverInstalledCollections: 862ms → 3msservermode: ~2.5s → 2.16s