fix(css): Merge duplicate nested at-rules#1917
Open
KSHITIZ6341 wants to merge 1 commit into
Open
Conversation
KSHITIZ6341
requested review from
JakeLane,
danieldelcore,
dddlr,
kylorhall-atlassian,
liamqma and
pancaspe87
as code owners
July 11, 2026 20:25
🦋 Changeset detectedLatest commit: 53068dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hooray! All contributors have signed the CLA. |
✅ Deploy Preview for compiled-css-in-js canceled.
|
liamqma
reviewed
Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is this change?
Merges duplicate children recursively when equivalent at-rules are nested, so repeated declarations under the same conditional scopes are emitted once.
Credit to @michaelabrahamian for providing the nested at-rule reproduction and expected output.
Fixes #1847
Why are we making this change?
mergeDuplicateAtRulesmerged matching top-level containers but treated each nested at-rule as an opaque serialized child. When nested blocks differed by even one declaration, both survived deduplication and produced redundant CSS.How are we making this change?
The plugin now merges equivalent sibling at-rules at each nesting level, deduplicates their children, and then recurses into the merged container. Matching remains scoped to the current parent, non-atomic
cssMapScopedrules remain untouched, and existing top-level ordering is preserved.A patch changeset for
@compiled/cssis included.Validation:
yarn test packages/css/src/plugins/__tests__/merge-duplicate-at-rules.test.ts --runInBand(6 tests)yarn test packages/css --runInBand(297 tests, 219 snapshots)yarn test --runInBand(5,132 tests, 436 snapshots)yarn lintyarn prettier:checkyarn buildNot run: visual regression tests, because this change operates on deterministic PostCSS output and has no rendered component changes.
PR checklist
Do not delete me!
I have...
website/(not required; no API or configuration change)