Repository navigation
Conversation
|
@kevin9327 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
2 tasks done
This branch has not been deployed
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 changed / motivation ?
The
timingsvalue normalizer turns millisecond values of 10ms and up into seconds withvalue / 1000 + 's'. That division is done in binary floating point, so many ordinary values come out with representation noise in the generated CSS:Other examples are
11.3ms→.011300000000000001s,13.8ms→.013800000000000002sand10.2ms→.010199999999999999s. Roughly a quarter of the one-decimal millisecond values from 10ms to 200ms are affected. The value means the same thing, but the CSS is longer than themsform it replaces, which defeats the point of the conversion ("shorter"), and the noise also ends up in the class-name hash input.The fix rounds the quotient to 15 significant digits (
Number((value / 1000).toPrecision(15))). That removes the noise and keeps every digit a CSS time value can carry. Values that already divided cleanly (1234ms→1.234s,10ms→.01s) are unchanged, and so are the existing inline snapshots.Linked PR/Issues
None. I found no open issue or PR about this.
Additional Context
New test in
packages/@stylexjs/babel-plugin/__tests__/transform-value-normalization-test.js:33.3ms,11.3ms, and atransitionshorthand with13.8msand10.2mscompile to.0333s,.0113sandopacity .0138s ease-in .0102s. It fails onmain(transition-duration:.033299999999999996s) and passes with the fix. The other 20 tests in that file still pass.I ran the babel-plugin suite from a sparse checkout with the published
@stylexjs/stylex/@stylexjs/shared0.19.1 instead of the workspace builds. In that setup 3 suites (transform-stylex-props-test.jsand two legacy suites, 7 tests) fail identically with and without this change; everything else passes.AI assistance: I used an AI coding assistant to help find and write this fix. I reviewed the change and ran the tests above myself.
Pre-flight checklist
Contribution Guidelines