Fix CSS deduping and missing chunks #7218
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Fix #6931
May also fix this issue: #7124 (cc @PxlBuzzard appreciate if you can test this after it's released)
The previous CSS deduping flow was incorrect, as it assumed a CSS module found in a SSR build applies to all pages, which isn't the case most of the time. This regression was introduced in #6582
I've fixed this by implementing a more correct CSS deduping strategy, that is to make sure SSR and client builds' generated CSS chunk ids are always derived the same way. That way the chunk name and content are always the same when written to fs.
I've put more in-code comments on how it works and why.
Testing
Added test from #6931. Made sure all other tests passed.
I'm also trying a new way to create the test, moving the new fixture code in
0-css/src/pages/client-only-and-ssr/
only. This way each new test we add are only new folders inpages/
Docs
n/a. bug fix.