Code-splitting issue
I recently upgraded from 1.120.18 to 1.126.8. We had been stuck for a while on 1.120 because of the false positive "could not find match from" issue that got solved a few days ago (https://github.com/TanStack/router/pull/4610).
But I noticed a big increase in the size of the main JS chunk after build. So far I have traced it down to somewhere between
1.121.2
(ok) and 1.121.12
(ko). Looking a little at which chunks remain, it looks like only the stuff we code-split manually (not through tanstack) is now emitted as a separate chunk, and everything else is in the main chunk.
I'm attaching a visualization (done w/ rollup-plugin-visualizer
) of the before and after. It's about a 5x increase in gzipped size.
We're using basic file routing on tanstack/react-router (no start). We don't touch the tree at all, not virtual routes or anything. The tsr.config
is also very basic, with autoCodeSplitting: true
. The Vite plugin has no options, but the issue remains unchanged if I try and set a custom codeSplittingOptions.defaultBehavior
.
I'll try and narrow this down even more. But in the meantime: is this a known issue? Or even an intended behavior change?

7 Replies
genetic-orange•2mo ago
not a known issue
equal-aquaOP•2mo ago
Ok I managed to get a minimal repro based on
npx create-tsrouter-app@latest my-app --template file-router
and it turns out that the "autoCodeSplitting": true
option in tsr.config.json
does NOT work anymore.
However, the fix is quite simple: just pass in autoCodeSplitting: true
to the Vite plugin. Maybe it makes sense because this option does not impact the routeTree generation, but only the build. It was a big surprise though!genetic-orange•2mo ago
sounds like a bug
cc @Sean Cassiere
rival-black•2mo ago
Is there an example of your routes file-tree that can be looked at?
Also, how does the
Route
get exported?
And does anything else get exported out of the route files?equal-aquaOP•2mo ago
The code you get from
npx create-tsrouter-app@latest my-app --template file-router
reproduces the issue if you change only this:
- remove autoCodeSplitting: true
from the vite.config
- add a tsr.config.json
file with { "autoCodeSplitting": true }
well, you do need to add a 2nd route with some content if you want to see code-splitting happen at all ðŸ«
if it helps, here's the route file tree of such a codebase
(i removed the comments to fit discord message limit)rival-black•2mo ago
I should have some time today. I'll try and take a stab at this.
The fix has been merged into
main
.
For whatever reason, CI is being a bit finicky at the moment, so a release hasn't gone through yet.
The release has gone through.rival-black•2mo ago
The fix should now be available in https://github.com/TanStack/router/releases/tag/v1.127.9
GitHub
Release v1.127.9 · TanStack/router
Version 1.127.9 - 7/15/25, 8:26 PM
Changes
Fix
solid-router: prevent client effects running on server (#4621) (ba590c2) by Indrek Ardel
router-plugin: composed plugin to consider options from json...