Post

I was debugging some chunking regressions in an app I work on when updating from Vite 7 to Vite 8. I got an AI to generate a tool to help figuring out what was wrong, and I uploaded it at nicolo-ribaudo.github.io/vite-compare/ in case it's useful for anybody else.

nicolo-ribaudo.github.ioVite bundle compareCompare two Vite bundle builds side-by-side: chunk diff, per-entry size analysis, module diff, and an interactive chunk/module graph.

5 reposts64 likes

Rolldown was over-splitting compared to Rollup, I had to manually configure some groups. It has something to do with cycles across chunks and modules imported both through a static and dynamic imports chain, but I cannot get a minimal reproduction to show the same behavior.

Tried now, unfortunately it's not very helpful. In my case it's telling me that chunk C is its own chunk because it's imported both by chunk A and chunk B, which is indeed true, but it does not explain why it cannot just put it inside chunk A (where chunk B is only imported through import() by A)

Actually, this AI-generated and not Vite-generated graph shows exactly my situation 😛 With this graph shape, Rolldown is automatically splitting what's called "vendor" here into its own chunk, while Rollup was putting it together with "index". There is no reason to split it as far as I can tell.

And this was happening for a whole bunch of modules, causing the number of chunks to increase from ~50 to ~80. The solution in this example would be to manually define a group containing the entry point of the "index" chunk, and then it automatically includes what would otherwise be in "vendor"

Also, for some reason (even if the docs say otherwise) Vite 7 was prioritizing the "package.json#module" field in some of my dependencies while Vite 8 prioritizes "package.json#browser", which caused a bunch of different stuff to be loaded.

Damn, exactly what happened to us trying Vite 8, I'm definitely giving this a try ❤️ We postponed the upgrade because of the massive chunking difference that ultimately led to worse metrics. Rolldown seemed much more aggressive in splitting automatically (in theory it's good, but not all the time).

There is already a Rolldown PR open that fixes the minimal reproduction I extracted out of my case, hopefully it fixes the problem for you too :)