Merged
Conversation
8b9caa0 to
fe51b4a
Compare
The first occurrence is for `& {}`, which is an edge case already
The second occurrence is for normal rules that are empty
There are some exceptions to this rule. Some at-rules can be body-less: ```css @charset "UTF-8"; @layer foo, bar, baz; @Custom-Media --modern (color), (hover); ```
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
c8952e3 to
92c2d1c
Compare
thecrypticace
approved these changes
Jan 31, 2025
| copy.name === '@layer' || | ||
| copy.name === '@charset' || | ||
| copy.name === '@custom-media' || | ||
| copy.name === '@namespace' |
Contributor
There was a problem hiding this comment.
Should this just be all at-rules? 🤔 Nevermind me here
Member
Author
There was a problem hiding this comment.
@media (foo) {}Should be removed imo
Contributor
There was a problem hiding this comment.
yeah i noticed this too, you just responded before i could update my comment heh
Member
Author
There was a problem hiding this comment.
Hehe, I think in theory we could invert the condition and don't touch everything but the @media (but then we need to check for @suspports as well.
In a perfect world @layer foo {} is also removed, (because you should use @layer foo; but we don't make that distinction.
philipp-spiess
approved these changes
Jan 31, 2025
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.
This PR is an optimization where it will not emit empty rules and at-rules. I noticed this while working on #16120 where we emitted:
There are some exceptions for "empty" at-rules, such as:
These don't have a body, but they still have a purpose and therefore they will be emitted.
However, if you look at this:
None of these will be emitted.