CSS is delivered via link tags, and link tags are not a list of... CSS files are not a container of module factories, they are basically a list of CSS rules that are loaded in order, and in order in order which you load your CSS files. So now everything is really global and has side-effects and the order matters, which makes a lot of stuff more complicated. So the order matters of the stuff, so we need to figure out in which order we place the modules in these chunks. You can no longer duplicate modules, because if you duplicate style rules, they basically appear in two different orders, that's breaking stuff.
You can sometimes overship modules, it depends on the type of styles you have. If you have CSS modules, they are isolated, have no side-effects, then you can overship them, but if you have global CSS it usually has side-effects or could have side-effects on your code, so it's not okay to just load it when the user didn't request it. In a summary, CSS is super easy to chunk, you have all the freedom to do, but CSS makes everything super hard. And especially because of ordering. And so when order matters, it's a hard problem. So how to figure out the order of placing CSS files in your chunks in the first place?
You could just think about, you could just do what the imports say, basically import order is the order of CSS loading. That works well, as long as you only have a single chunk group, if you only have a single page, no async imports and that stuff, that works well, because then there's a defined import order. But when you have multiple chunk groups and multiple chunk groups are loaded in any order, we don't know which page is visited first by the user and that stuff, they could all be loaded at the same time, like page and async import is loaded at the same time. And so in this case, there's a multiple defined import order of all these chunk groups, and in practice, there's always conflicts between them. It's not possible to have always the same order of imports.
Comments