Server Components: RSC client runtime lands in the shared entry chunk even when one route uses it

Offen
#8,941 1 Kommentar 1 Reaktion 2 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@schiller-manuel arbeitet bereits daran.

Seit 15.11.2026.

  • #8942 von @schiller-manuel — offen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

Versions

  • @tanstack/react-start 1.169.5, @tanstack/react-router 1.170.46, @tanstack/react-start-rsc 0.1.66
  • @vitejs/plugin-rsc 0.5.39, Vite 8 (Vite+ core 1.5.0), React 19.3.1, production build

What happens

With tanstackStart({ rsc: { enabled: true } }) and rsc(), one route that calls renderServerComponent(<p>…</p>) from a server function adds the RSC client runtime to the shared entry chunk, so every route pays for it, not only the route that uses Server Components.

Same app and sources, before and after adding that one route (vite build --sourcemap, bytes attributed per source file through the maps):

before after
all client JS, raw 1,663,509 B 1,674,859 B (+11,350)
all client JS, gzip 554,604 B 560,321 B (+5,717)
shared index chunk, raw 303,755 B 329,464 B
shared index chunk, gzip 96,334 B 104,493 B (+8.2 kB)

Sources in the index chunk afterwards include @tanstack/react-start-rsc/dist/esm/rscCssEnvelope.js, reactSymbols.js, awaitLazyElements.js and ServerComponentTypes.js; @vitejs/plugin-rsc accounts for about 19 kB raw.

Expectation

For an app that adopts Server Components on a few routes, I'd expect the Flight client runtime to load with those routes' chunks (or lazily on first use), not in the entry chunk. Is that something that can be code-split today, for example through the route's lazy chunk, or is the entry chunk the intended place? If it is intended, a note in the Server Components guide about the fixed client cost would help people size the trade-off.

Vorherrschende Sprache
TypeScript
Sterne
15.3k
Forks
1.9k
Ø Merge
1 T. 5 Std.
Gemergte PRs (30 T.)
46

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TanStack/router

Alle Issues in TanStack/router

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.