SSR: no automatic image preloads for eager <img> elements (React emits <link rel="preload" as="image">)
維護者通常 1 天內回覆
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- react, typescript
- 領域
- backend
研究方向
Start by comparing Redact's server renderer with React's pushImg behavior in ReactFizzConfigDOM, then inspect how Redact collects head elements during rendering. Reproduce the issue with the provided renderToString example and check eager images with src, srcSet, loading="lazy", and fetchPriority. Done means matching React's image preload output and ordering; the linked open pull request #100 shows work is already underway.
由索引模型根據 Issue 內容生成。
描述
Version: @tanstack/redact 0.2.1 (same on 0.2.0), TanStack Start 1.168 on Cloudflare Workers, Vite plugin with ssr: { noExternal: true }. Baseline: react-dom 19.3.
React's streaming server renderer emits a <link rel="preload" as="image"> in <head> for images it renders eagerly: every <img> with a src or srcSet that is not loading="lazy", placed before the stylesheet when fetchPriority="high" and after it otherwise (pushImg in ReactFizzConfigDOM). Redact's server renderer emits none, so the browser only discovers the hero image once the parser reaches it in the body.
Same route rendered by both runtimes, head only. React:
<meta charSet="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="preload" as="image" href="/favicon.svg"/>
<link rel="preload" as="image" imageSrcSet="/games/desk-crawler/screen-sample-800.png 800w, /games/desk-crawler/screen-sample.png 1200w" imageSizes="(min-width: 1024px) 560px, 100vw" fetchPriority="high"/>
<link rel="preload" as="image" href="/games/desk-crawler/icon-192.png"/>
<link rel="preload" as="image" href="/games/idle-angler/icon-192.png"/>
<link rel="stylesheet" href="/assets/styles-….css" data-precedence="default"/>
<title>…</title>
Redact:
<link rel="stylesheet" href="/assets/styles-….css" data-precedence="default"/>
<title>…</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
The <img> elements themselves are rendered identically in both (srcset, sizes, fetchpriority="high" all present), and the font <link rel="preload"> elements rendered in the route's head come through fine. It is only the image preloads React synthesises from <img> that are missing.
A smaller related difference, visible above: React hoists <meta charset> and <meta name="viewport"> to the very start of <head>, ahead of stylesheets and the title. Redact keeps them in document order after the stylesheet and title. Here the charset lands at byte 219, inside the 1024-byte window, so it is harmless, but a page with a long stylesheet list or title could push it past the limit.
Reproduction: a renderToString of
<html><head><link rel="stylesheet" href="/a.css" precedence="default" /><title>t</title><meta charSet="utf-8" /></head>
<body><img src="/hero.png" fetchPriority="high" alt="" /></body></html>
gives <meta charSet="utf-8"/><link rel="preload" as="image" href="/hero.png" fetchPriority="high"/><link rel="stylesheet" …/><title>t</title> on react-dom/server, and <link rel="stylesheet" …/><title>t</title><meta charset="utf-8"/> with no preload on @tanstack/redact/server.
- 主要語言
- TypeScript
- 星號
- 581
- 分支
- 28
- 平均合併
- 13 小時 48 分鐘
- 30 天內合併 PR
- 45
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TanStack/redact 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 4/5 1-2 天 新手友好度 35/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 20/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
fb55/htmlparser2#2579 ·
維護者通常 1 天內回覆
-
bug good first issue needs-review
難度 1/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
documentation public
難度 1/5 1-3 小時 新手友好度 68/100
midnightntwrk/umbradb#65 ·
維護者通常 2 天內回覆
-
area/channels kind/bug priority/medium
難度 2/5 1-3 小時 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 則留言 ·
維護者通常 1 天內回覆
-
needs verification
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 13 天內回覆