Code splitting (vendor chunks) in TanStack Start + Vite 8 + Rolldown #7712
-
|
In the client build for a TanStack Start application (using Vite 8 and Rolldown), is there a way to configure code splitting in I tried various configuration options which work in plain rolldown-vite, but couldn't get any of them to work in TanStack Start. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
In Start this needs to target the Vite client environment, because the Start plugin creates separate Try putting the chunking under export default defineConfig({
environments: {
client: {
build: {
rolldownOptions: {
output: {
manualChunks(id) {
if (id.includes('/node_modules/')) return 'vendor'
},
},
},
},
},
},
plugins: [tanstackStart(), react()],
})The key bit is the |
Beta Was this translation helpful? Give feedback.
Alright, I found the issue. The problem is that TanStack's default client entry is
@tanstack/react-start/dist/plugin/default-entry/client.tsxwhich is a file insidenode_modules. A plainid.includes("/node_modules/")check matches the entry module itself.We can work around this by excluding this specific module from the vendor bundle:
This issue should also go away when a custom entry module is configured:
I'm still wondering whether this is wor…