Skip to content

Conversation

@nmn
Copy link
Collaborator

@nmn nmn commented Sep 25, 2025

What changed / motivation ?

stylex.props should be able to precompile to a static string or a simple expression that chooses from pre-compiled strings and skip runtime merging of classNames when all styles are defined and available statically in the same file.

Today, this is limited to direct usages only.

This PR expands that to be able to pre-compile simple expressions and constants as well, but still, intentionally bail in the case of all imports.

This should improve overall performance when StyleX styles are being used entirely locally without any cross-file style composition.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 25, 2025
@github-actions
Copy link

github-actions bot commented Sep 25, 2025

workflow: benchmarks/perf

Comparison of performance test results, measured in operations per second. Larger is better.

[email protected] compare
node ./compare.js /tmp/tmp.bfJTQYazDc /tmp/tmp.0sZLBZCArB

Results Base Patch Ratio
babel-plugin: stylex.create
· basic create 634 644 1.02 +
· complex create 202 202 1.00
babel-plugin: stylex.createTheme
· basic themes 467 461 0.99 -
· complex themes 43 43 1.00

@github-actions
Copy link

github-actions bot commented Sep 25, 2025

workflow: benchmarks/size

Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.

[email protected] compare
node ./compare.js /tmp/tmp.3570HFI5Xi /tmp/tmp.Q0E7aH2T6B

Results Base Patch Ratio
@stylexjs/stylex/lib/cjs/stylex.js
· compressed 1,278 1,278 1.00
· minified 3,986 3,986 1.00
@stylexjs/stylex/lib/cjs/inject.js
· compressed 1,223 1,223 1.00
· minified 3,216 3,216 1.00
benchmarks/size/.build/bundle.js
· compressed 496,650 496,650 1.00
· minified 4,847,840 4,847,840 1.00
benchmarks/size/.build/stylex.css
· compressed 99,853 99,853 1.00
· minified 747,541 747,541 1.00

@mellyeliu
Copy link
Member

@nmn looks like there's still a few failures. will get you a repro soon

@nmn nmn force-pushed the feat/descendent-sibling branch from 2c942f8 to e84cf6a Compare September 27, 2025 22:01
@nmn nmn changed the title Feat/descendent sibling Enhance stylex.props to precompile more often Sep 27, 2025
@mellyeliu
Copy link
Member

will attempt a resync soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants