fix(docs): bundle navigation icons to prevent client-nav flash#2288
Draft
benjamincanac wants to merge 2 commits into
Draft
fix(docs): bundle navigation icons to prevent client-nav flash#2288benjamincanac wants to merge 2 commits into
benjamincanac wants to merge 2 commits into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
.ts files and navigation.yml for client bundle
.ts files and navigation.yml for client bundle.ts and navigation.yml for client bundle
.ts and navigation.yml for client bundle.ts and navigation.yml for icon client bundle
Contributor
📝 WalkthroughWalkthroughThe client bundle icon scan setting now uses an explicit Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
.ts and navigation.yml for icon client bundle97073bd to
0feee38
Compare
0feee38 to
5f66098
Compare
Docs nav icons render in @nuxt/icon CSS mode. On initial load their mask CSS is inlined via SSR, but on client-side navigation the icon data isn't in the client bundle, so it's fetched from the iconify API and the rule is injected after paint — a visible flash. The icons used only by the remote nuxt/nuxt docs nav (md frontmatter `navigation.icon` + `.navigation.yml`) can't be collected automatically: - the scanner skips the `.data` dot-dir (remote docs), and - @nuxt/content restores its cache on CI (0 files parsed), so parse hooks and raw-file globbing both come up empty at build time. Inline just those remote-only icons (validated against the installed @iconify-json packages). Local content (deploy, blog, …) and app icons stay covered by `scan`; widen its glob to include `.ts` and `**/.*.{yml,yaml}` so app config and local `.navigation.yml` dotfiles are picked up too. Verified: client bundle 215 -> 262 icons (143.57KB, under the 256KB limit), including all folder-type/file-type docs nav icons; local icons (azure, blog nav) confirmed still bundled via the scanner.
5f66098 to
9357ace
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Docs navigation icons (e.g. on
/docs/4.x/getting-started/installation) flash in on client-side navigation. They render in@nuxt/icon's CSS mode (class="iconify i-lucide:book-marked"). On a hard refresh the mask CSS is inlined via SSR (onServerPrefetch), so it's fine — but on client-side route changes the icon data isn't in the client bundle, so it's fetched from the iconify API and the CSS rule is injected after paint → flash.Icons used only by the remote docs nav (md frontmatter
navigation.icon+.navigation.yml) can't be collected automatically at build time:clientBundle.scanskips them — remote docs are cloned under the.datadot-dir, ignored under tinyglobbydot:false.content:file:beforeParse) don't help —@nuxt/contentrestores its cache on CI (✔ … 972 cached, 0 parsed), so nothing is parsed and the hook never fires..data/contentfiles doesn't help either — repos aren't re-cloned on cached CI builds.(All three verified empirically with local builds.)
Fix
Inline the remote-docs-only icon list into
icon.clientBundle.icons— the only build-state-independent source (data loaded from the installed@iconify-json/*packages at build). Collected across all three served versions (nuxt/nuxt3.x,4.x,main) — important because some icons are version-specific (e.g.vscode-icons:folder-type-apponly appears in 4.x'sapp/directory structure). Every entry is validated against the installed packages (an unresolvedclientBundle.iconsentry would fail a production build).Local content (deploy, blog, …) and app icons stay covered by
scan; its glob is widened to include.ts(app config) and**/.*.{yml,yaml}(local.navigation.ymldotfiles).Refreshing the list
Regenerate when docs add icons — grep all three branches for
i-<collection>-<name>and subtract whatscanalready covers (app + localcontent/).Verification
Local production build: client bundle 215 → 262 icons (143.57 KB, under the 256 KB limit), including all
folder-type-*/file-type-*docs nav icons. Cross-checked the 3.x/4.x/main branches against the bundle — initial main-only list missedvscode-icons:folder-type-app+simple-icons:google; both now included.