Skip to content
Source
Sign inSign up
TanStack/router

Root route modulepreloads all route chunks in large projects (Vite 8 / Rolldown) #7197

Send to my agent
ClosedZacharyL2(GitHub profile, opens in a new tab) opened this issue 5 comments

Describe the bug

In large projects, the root route ends up with all route chunks in its modulepreload list, which is inherited by every SSR'd page. For a 150+ route app this means 80–150+ <link rel="modulepreload"> tags on every server-rendered HTML response.

Context / motivation

I ran into this while looking at SSR HTML size. Every server-rendered page carried a large block of preload tags inherited from the root route, adding a few KB of inline path strings to the critical TTFB payload regardless of which page the user actually requested.

Minimal reproducible example

https://github.com/ZacharyL2/tsr-modulepreload-repro

Steps to reproduce

git clone https://github.com/ZacharyL2/tsr-modulepreload-repro
cd tsr-modulepreload-repro
pnpm install
pnpm build
pnpm inspect

Output: root preloads: 156. 214 routes with typical head() / loader() — triggers the issue naturally.

Expected behavior

Root should only carry the entry chunk and truly shared deps, not chunks owned by specific routes.

Platform

  • @tanstack/start-plugin-core: 1.167.35
  • @tanstack/react-start: 1.167.41
  • @tanstack/react-router: 1.168.22
  • vite: 8.0.8 (Rolldown)

Real-world observation (production app, 152 routes)

  • Root preloads: 82
  • / modulepreloads: 103
  1. please provide a reproducer project that actually exhibits this issue without having to simulate

  2. schiller-manuel(GitHub profile, opens in a new tab) added labelsinformation needed

  3. @schiller-manuel Sorry, the previous repro was AI-generated and I didn't review it carefully. Updated it — no simulation needed, pnpm build triggers it naturally. Also verified on a production app (152 routes): root preloads 82 → 12 with the fix.

  4. schiller-manuel(GitHub profile, opens in a new tab) removed labelsinformation needed

  5. your PR does not fix the actual issue. it just prevents emitting the preloads. but the chunks will still be loaded via JS then. So it's even worse now since this introduces a waterfall:

    Image

    The actual issue is rolldown creating separate chunks for shared code between static and dynamic imports.

  6. @schiller-manuel Thanks for tracking this upstream.

    For context on the original motivation: I came at this from the SSR HTML size angle, not the loading angle. In our production app (152 routes), every server-rendered HTML response carried 80+ tags inherited by every page — a few KB on the critical TTFB payload I was trying to trim. Filtering at the manifest layer looked like a cheap local win, but as you pointed out, removing only the hint while leaving the static imports turns parallel discovery into a waterfall. Net loss.

    Happy to follow rolldown#9154 and test against our app once it lands.

  7. this is already fixed in rolldown rc-16 vite is pinned to rc-15, so either override or wait for a new vite release

Sign in to join this conversation.