Skip to content

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

Closed

Description

@ZacharyL2

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

Activity

  1. schiller-manuel commented on Apr 16, 2026

    @schiller-manuel
    Collaborator

    please provide a reproducer project that actually exhibits this issue without having to simulate

  2. added
    information needed
    on Apr 16, 2026
  3. ZacharyL2 commented on Apr 17, 2026

    @ZacharyL2
    Author

    @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. removed
    information needed
    on Apr 17, 2026
  5. schiller-manuel commented on Apr 18, 2026

    @schiller-manuel
    Collaborator

    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. ZacharyL2 commented on Apr 18, 2026

    @ZacharyL2
    Author

    @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. schiller-manuel commented on Apr 18, 2026

    @schiller-manuel
    Collaborator

    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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions