SSR: no automatic image preloads for eager <img> elements (React emits <link rel="preload" as="image">)

オープン
#97 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@barrymichaeldoyle がすでに取り組んでいます。

2026年10月28日 から。

  • #100 @barrymichaeldoyle による — オープン

評価

難易度
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分
マージ済み PR(30日)
45

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/redact のほかの issue

TanStack/redact の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。