stylex icon indicating copy to clipboard operation
stylex copied to clipboard

[wip] feat: style injection for `defineConsts` hot reloading

Open mellyeliu opened this issue 8 months ago • 3 comments

add style injection for dev mode hot reloading

we need to add special handling for defineConsts, because the LTR string is empty (just a placeholder) and the actual data is stored in the key value pair

high level approach:

  • build dependency map of consts to rules being modified
  • process rules, when consts is modified, go back to previous rules dependent on it and replace the vals

very wip... debugging.....

mellyeliu avatar Apr 17 '25 09:04 mellyeliu

workflow: benchmarks/perf

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

[email protected] compare node ./compare.js /tmp/tmp.hompA8XilU /tmp/tmp.DtqPBmCrY2

Results Base Patch Ratio
babel-plugin: stylex.create
· basic create 546 535 0.98 -
· complex create 199 185 0.93 !!
babel-plugin: stylex.createTheme
· basic themes 471 461 0.98 -
· complex themes 43 42 0.98 -

github-actions[bot] avatar Apr 17 '25 10:04 github-actions[bot]

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.oXNaJxEjpT /tmp/tmp.xoAb2K0Imq

Results Base Patch Ratio
stylex/lib/stylex.js
· compressed 900 900 1.00
· minified 2,943 2,943 1.00
stylex/lib/StyleXSheet.js
· compressed 1,266 1,753 1.38 !!
· minified 3,776 5,432 1.44 !!
benchmarks/size/.build/bundle.js
· compressed 537,611 537,611 1.00
· minified 7,435,904 7,435,904 1.00
benchmarks/size/.build/stylex.css
· compressed 100,609 100,609 1.00
· minified 755,721 755,721 1.00

github-actions[bot] avatar Apr 17 '25 10:04 github-actions[bot]

will wait to rebase on https://github.com/facebook/stylex/pull/1017

mellyeliu avatar Apr 23 '25 21:04 mellyeliu

closing, will revisit as we explore runtimeInjection alternatives/reassessments

mellyeliu avatar Jul 03 '25 16:07 mellyeliu