#Issues regarding auto codesplitting

2 messages · Page 1 of 1 (latest)

wise path
#

I have spent several days now trying to improve and decrease the bundle size of my application. Originally pre-optimization the bundle size was around 2,2mb & 700kb+ (gzipped). I am creating this post now because it feels like I am not able to get the auto codesplitting to work properly..

Based on posts i have read, the auto codesplitting is automatically turned on - and i can notice that there are warnings that routes will not be autosplitted if there is an export etc ...

When visiting the main dashboard (authenticated) this is our chunk (first image): 307kb (the biggest one)
When visiting the login page (unauthenticated) our chunk is still the same (second picture): 307kb (the biggest one).

It does not seem like Tanstack Start are properly codesplitting the routes? Because visiting login route which is barely any component usage pulls in the whole bundle, the same bundle as dashboard pulls in.

Originally the main chunk is supposed to be like 700kb+ but I have added a lot of manual chunks inside of vite.config.ts to separate those chunks into more "smaller" ones to make the main chunk smaller, but the total size is still the same when adding all chunk sizes together.

Stack:

  • Turborepo
  • Vite v 7.3.1
  • Build preset with Nitro
  • Have separate packages for UI, Config etc.
  • 3 apps in the monorepo (app, web, docs)

Willing to work more on this with anyone who can help, I can share more code etc.