-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not emit empty rules/at-rules #16121
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 <[email protected]>
Co-authored-by: Jordan Pittman <[email protected]>
c8952e3
to
92c2d1c
Compare
copy.name === '@layer' || | ||
copy.name === '@charset' || | ||
copy.name === '@custom-media' || | ||
copy.name === '@namespace' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this just be all at-rules? 🤔 Nevermind me here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@media (foo) {}
Should be removed imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i noticed this too, you just responded before i could update my comment heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.