T
TanStack11mo ago
fair-rose

autoCodeSplitting causes entire app rerender

When autoCodeSplitting is set to true in vite config, every time I change anything in a route.tsx file, entire app re-renders. If i extract the part I want to change in a separate file (so not only component but new file) then only the component itself re-renders. Disabling the plugin makes everything work normally, ie. changing something in a route.tsx file doesn't rerender the entire app, just the part that got changed. This is what vite outputs as being updated with autoCodeSplitting on:
[vite] hmr update /src/styles/globals.css, /src/providers/tanstack-router-provider.tsx, /src/routes/~_auth/~login/~route.tsx?tsr-split (x2)
[vite] hmr update /src/styles/globals.css, /src/providers/tanstack-router-provider.tsx, /src/routes/~_auth/~login/~route.tsx?tsr-split (x2)
(tanstack-router-provider.tsx is just a file where I inject the data into router context and return the tsr RouterProvider wrapper) This is with off:
16:33:58 [vite] hmr update /src/routes/~_auth/~login/~route.tsx, /src/styles/globals.css
16:33:58 [vite] hmr update /src/routes/~_auth/~login/~route.tsx, /src/styles/globals.css
4 Replies
wise-white
wise-white11mo ago
can you please provide a complete minimal example with exact repro steps?
fair-rose
fair-roseOP11mo ago
any example just setting the option above to true, for eg forked basic file based routing example: https://stackblitz.com/edit/tanstack-router-vtnul4?file=src/routes/index.tsx,vite.config.js,src/routes/_layout.tsx&preset=node try changing anything inside any of the route files (index/posts/etc..) and you will see the entire page flashing instead of just the part in the route.
wise-white
wise-white11mo ago
thanks, can you please create a github issue so this gets tracked?
fair-rose
fair-roseOP11mo ago
sorry for the delay, opened it here: https://github.com/TanStack/router/issues/2676
GitHub
autoCodeSplitting causes entire app re-render · Issue #2676 · TanSt...
Which project does this relate to? Router Describe the bug When autoCodeSplitting is set to true in vite.config.ts, every time I change anything in a route file, entire app re-renders. If i extract...

Did you find this page helpful?