fix(hmr): preserve CSS module order during partial updates
During HMR, an updated CSS module was re-appended to the end of <head>, so a sheet that used to load first could suddenly override everything after it. In large apps that showed up as a flash of unstyled — or wrongly styled — content on every save. 40+ users reported it across three issues.
- 1Tracked the original import order of every CSS module in the client module graph.
- 2On a partial update, re-inserted the sheet before its next sibling instead of appending it.
- 3Kept the fast path: in-place textContent swaps still skip the DOM walk entirely.
- 4Added an e2e playground with 60 interleaved CSS modules to lock the order in.
Maintainers asked for numbers on a 1,000-module app first — the extra DOM walk cost under 0.3 ms per update, and that settled it. Approved by two core maintainers.
> Shipped in Vite 6.0.3. Closed 3 issues reported by 40+ users; no FOUC regressions since.