Debugging huge bundle sizes
Hey there! I've been shipping TSS in production and I noticed that even on small routes my bundle size is quite large. Over 500 kilobytes to be exact πΆβπ«οΈ
I don't think I quite understand how TSS/TSR is doing code splitting as the offending route is a landing page which I have explicitly isolated from the rest of the application. It does not use server functions. It does not import anything from the main application layout. It was purpose built to be a quick-loading marketing page.
Its performance is good. It gets good Lighthouse/PSI scores and all of that. But that bundle size is hurting me inside. Does a massive client bundle just get shipped with every route? Or are there more things I can do to debug this?
8 Replies
correct-apricotβ’6mo ago
which bundle size exactly?
the client bundle?
stormy-goldOPβ’6mo ago
yes
correct-apricotβ’6mo ago
and whats inside of that bundle? aside from react, router and start?
code splitting means:
there is a client bundle that contains all "base stuff" and everything that you use in the root route
and then each route component will be split off (unless you configure the splitting differently) into a separate chunk
so if you use some bigger deps in the root route, that will be in the client bundle
stormy-goldOPβ’6mo ago
right i get all that. i've kept my
routes/__root.tsx
super minimal for that reason:
I made a tiny routes/test.tsx
route just to validate this:
after running build and start, i load up the route....and pull down a 500kb bundle? i just don't see where that number is coming from in this setup. that feels like its pulling the payload for the entire app.
stormy-goldOPβ’6mo ago
yes i use posthog and some toast component - but surely we are nowhere near the reported 532kb.
correct-apricotβ’6mo ago
so whats inside that file?
stormy-goldOPβ’6mo ago
what appears to be minified javascript for the entire app. for example, heres a feedback box component from an entirely separate (and not imported! route):
correct-apricotβ’6mo ago
interesting
cc @Sean Cassiere
i cannot reproduce this in the start-basic example
i only find the root route in the client bundle
where is that feedback form component defined?
and where is it imported?