fix(dev): silence icon SSR failures and stale optimizeDeps warning - #125
Merged
Conversation
dev サーバーの 2 種類の警告を解消する:
1. "[Icon] failed to load icon mdi:github / lucide:rss"
- nuxt 4.5 では @nuxt/icon の SSR が使う useRequestFetch().native が
内部呼び出し不能な素の fetch になり、相対 URL (/api/_nuxt_icon/...) の
取得が全アイコンで失敗していた(upstream 起因)
- 相対 URL だけ Nuxt の $fetch 経由に差し替える server plugin を追加
- あわせて使用中の lucide コレクションを @iconify-json/lucide として
ローカルインストールし、mdi と同じくサーバーバンドルに含める
(build 時に毎回出ていた lucide:rss の取得失敗 ×6 も解消)
2. "[NUXT_B7002] vite.optimizeDeps.include: @nuxtjs/mdc > extend"
- @nuxtjs/mdc 0.22 が optimizeDeps に "extend" (unified の旧 CJS 依存) を
追加し続けているが、unified 11 は extend に依存しないため解決不能だった
- 他の remark 系と同様に extend を devDependencies に追加して解決可能にする
lint / build / tsc 成功、build の icon 警告ゼロ、OG 画像生成も正常を確認。
@nuxt/icon 2.5.0 / @nuxtjs/mdc 0.22.2 の修正版が出たら plugin と extend は
削除できる。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Fixes two kinds of warnings that flooded the dev server.
1.
[Icon] failed to load icon mdi:github / lucide:rssRoot cause (upstream, already reported as nuxt/icon#518, fix pending as nuxt/icon#527):
_api.setFetch($fetch.native). Up to 2.2.3 the$fetchhere was Nuxt's global ofetch instance, whose.nativeis the internal-capable local fetch — this worked. Since 2.4.0 the plugin switched touseRequestFetch(), which during SSR returns Nitro'sevent.$fetch— a bare function with no.nativeproperty (nitropack 2.13.4runtime/internal/app.mjs)setFetch(undefined), and @iconify/vue'ssend()aborts every icon request viaif (!fetchModule) callback("abort", 424)— that is what the warnings are (with the real damage that icons never make it into the SSR HTML)Fix:
app/plugins/icon-ssr-fetch.server.tsthat routes relative URLs through Nuxt's$fetch(capable of internal calls). Since @nuxt/icon puts@iconify/vueintovite.resolve.dedupe, the patch lands on the same_apisingleton@iconify-json/lucide, bundling it server-side like mdi (this also fixes the 6xlucide:rssfetch failures that appeared on every build)2.
[NUXT_B7002] vite.optimizeDeps.include: @nuxtjs/mdc > extendRoot cause (initial explanation corrected):
unified 11 no longer depends on extend→ wrong. unified@11.0.5 still depends onextend ^3.0.0@nuxtjs/mdc > extendentry asks Vite to resolveextendfrom @nuxtjs/mdc's own package context, butextendis a dependency of unified, not a declared dependency of mdc itself, so pnpm's isolated node_modules cannot resolve it (hoisted npm/yarn layouts resolve it by accident, which is why upstream does not notice; long-standing report: Without shamefully-hoist, it fails to resolve dependency present in 'optimizeDeps.include' nuxt-content/mdc#174). Nuxt 4.5's B7002 warning made it visibleFix: add
extendto root devDependencies. The root node_modules is on the resolution walk-up path from pnpm's store directories, so the entry becomes resolvable (warning confirmed gone)Verification
pnpm buildwith zero icon warnings (previously 6x lucide:rss) and 11 OG images generatedpnpm lint/tsc(both app and node projects) passNotes
_api.setFetch($fetch.native)disables icon loading entirely —useRequestFetch()returns Nitro'sevent.$fetch, which has no.nativenuxt/icon#518 and an upstream fix PR (fix: added adapter to fix the SSR Icon missing error nuxt/icon#527, open, CI green, awaiting maintainer review) already exists — no new issue/PR neededextendcan be removed🤖 Generated with Claude Code