-
Notifications
You must be signed in to change notification settings - Fork 374
Improved media query sorting #1438
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
workflow: benchmarks/perfComparison of performance test results, measured in operations per second. Larger is better.
|
workflow: benchmarks/sizeComparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.
|
bd9b294 to
0907967
Compare
mellyeliu
left a comment
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.
Couple changes! Let's also add this behind a config within processStylexRules so we can roll it out easily - there are breakpoints that will shift internally.
| 0: { | ||
| className: "xrvj5dj x1rkzygb x7k18q3 x17lh93j xmr4b4k xesbpuc x15nfgh4", | ||
| "data-style-src": "../../../../../../../../../html/js/FooBar.react.js:11; ../../../../../../../../../html/js/FooBar.react.js:16" | ||
| "data-style-src": "../../../../../../../html/js/FooBar.react.js:11; ../../../../../../../html/js/FooBar.react.js:16" |
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.
These are irrelevant, you might need to do a clean yarn install
| return classname1.localeCompare(classname2); | ||
| } else { | ||
| if (rule1.startsWith('@') && !rule2.startsWith('@')) { | ||
| if (rule1.startsWith('@') && rule2.startsWith('@')) { |
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.
We don't want to affect the sorting of other at-rules like @keyframes or similar. Let's limit this to media queries first (@media)
…imit breakpoint sorting to @media rules only.
| if (maxWidth1Match && maxWidth2Match) { | ||
| const value1 = parseFloat(maxWidth1Match[1]); | ||
| const value2 = parseFloat(maxWidth2Match[1]); | ||
| if (value1 !== value2) { | ||
| return value1 - value2; | ||
| } | ||
| } |
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.
This comparison currently sorts while ignoring the unit. I'd suggest either assuming that 1rem === 16px for the sake of comparison, or, always sorting by units first, such, that rem < em < px as we can assume px media queries are more "specific".
What changed / motivation ?
Linked PR/Issues
Better media query sorting #1407
Additional Context
Ran and updated tests.
Pre-flight checklist
Contribution Guidelines