facebook / stylex

StyleX is the styling system for ambitious user interfaces.
https://stylexjs.com
MIT License
8.22k stars 303 forks source link

fix: usage of styles in a loop and non-existent styles #527

Closed nmn closed 2 months ago

nmn commented 2 months ago

Found and fixed a bug in the optimisation step for optimising stylex.props() and stylex() calls within a for-of loop.

The custom evaluate logic would fail to bail out and throw a null pointer exception instead.

The fix was to check for that null value and bail out instead.


Also, internally there are some rare example of non-existent styles (styles.unknown) being used which can cause the Babel plugin to throw an error.

Added a check to bail out instead of throwing an error for such cases and added a couple of test cases to verify that the fix works for stylex(), stylex.props() and stylex.attrs().

github-actions[bot] commented 2 months ago

compressed-size: runtime library

Size change: 0.00 kB Total size: 2.52 kB

View unchanged | Filename: gzip (minify) | kB size | kB change | % change | | :--- | :--- | :--- | :--- | | `./packages/stylex/lib/stylex.js` | **1.04** (3.22) | **0.00** (0.00) | **0.0%** (0.0%) | | `./packages/stylex/lib/StyleXSheet.js` | **1.48** (3.75) | **0.00** (0.00) | **0.0%** (0.0%) |
github-actions[bot] commented 2 months ago

compressed-size: e2e bundles

Size change: 0.00 kB Total size: 1128.74 kB

View unchanged | Filename: gzip (minify) | kB size | kB change | % change | | :--- | :--- | :--- | :--- | | `./apps/rollup-example/.build/bundle.js` | **1005.32** (10185.35) | **0.00** (0.00) | **0.0%** (0.0%) | | `./apps/rollup-example/.build/stylex.css` | **123.42** (774.34) | **0.00** (0.00) | **0.0%** (0.0%) |