-
Notifications
You must be signed in to change notification settings - Fork 310
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
feat: Implement style-value-parser to stylex normalize-value and improvements in style-value-parser #754
base: chore/css-value-parser
Are you sure you want to change the base?
Conversation
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.
- Changes look good.
- We will need some tests to verify that invalid strings fail to parse.
- All the signals are red. Let's fix that.
0a83c00
to
4b70761
Compare
13c1711
to
4fe7772
Compare
There is a concern here: Performance Adding manual parsing for all style values significantly slows down the time it takes to compile. |
workflow: benchmarks/sizeComparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.
|
…re than 3 characters, fixed box-shadow inset
1cf1341
to
b6d2ffa
Compare
NOTE: The custom style-value-parser causes a significant hit to compile time performance. The rollup example, which compiles a very large bundle went from about 10s to about 3m after using This is far too slow to be viable, so I tried The performance impact is negligible with numbers between 10.5 and 12s. Lightningcss does not have an API to parse style values specifically and any custom logic needs to be implemented as a visitor. The performance is good, but the current implementation is forced to use some hacky string manipulation to extract the style value from the minified CSS generated by LightningCSS. We should keep looking for an even better solution before shipping this. |
Implementing style-value-parser
packages/shared/src/utils/normalize-value.js
now uses style-value-parser, the package is responsible for parsing CSS values. The goal is to better "cannonicalize" CSS values, and provide a more modular way to scale canonicalization for future.Behavior
If the value fails to parse, it will default back to use the postcss-value-parser.
Improvements in style-value-parser
Created
appearance
andmargins
propertiesAdded tests for:
packages/style-value-parser/src/css-types/color.js
Created CSS Variable (packages/style-value-parser/src/css-types/css-variable.js) css type. It is not being used anywhere yet due to being recursive and not having an end case yet.
Improved
properties.js
by cleaning up import/exports