-
-
Notifications
You must be signed in to change notification settings - Fork 721
fix(transformer/styled-components): do not insert space when removing block comments in CSS minification #13381
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
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #13381 will improve performances by 4.02%Comparing Summary
Benchmarks breakdown
|
fbb8ccc to
84630cd
Compare
17636b0 to
0a54e8a
Compare
0a54e8a to
c900b3e
Compare
84630cd to
479abab
Compare
… block comments in CSS minification
479abab to
66cef68
Compare
|
I've concluded this is wrong. Have taken a different approach in #13390. |
|
It seems it is okay not to insert a space if the block comment is between a selector; however, a space is necessary in the value. Input .v/* block comment */.b {
padding: 10px/* block comment */20px
}Output generated by https://css.github.io/csso/csso.html .v.b{padding:10px 20px}However, I suppose we cannot determine where the block comment is. |
|
Thanks for coming back. Hmm. By the looks of CSSO, there's a lot more minification optimizations we could make. But do we want to get into that? I've opened an issue in the backlog: oxc-project/backlog#179 My recent flurry of PRs have mostly been about simplifying the minification algorithm, and making sure we do insert whitespace where it's necessary for correctness. Removing more unnecessary whitespace has been a pleasant byproduct. |

Previously we inserted a space in place of a block comment. I think it's probably unnecessary.
Input:
Previous output post-minification:
After this PR:
I'M NOT COMPLETELY SURE ABOUT THIS ONE. That behavior and the "Add a space when this is a own line block comment" comment were there in the original version before I refactored it in #12224, but I never understood its purpose.
There may be a good reason that I'm missing why it needs to be as it is, in which case this PR is wrong. All the conformance tests still pass (maybe just be due to inadequate test coverage), but there's a unit test showing the old behavior.
@Dunqing Can you advise?
Edit: Yes, I think this change is wrong. In browser, CSS
padding: 10/* */0behaves likepadding: 10 0, notpadding: 100.