Skip to content

Improve native createTheme token normalization#489

Closed
yaminyassin wants to merge 1 commit into
react:mainfrom
yaminyassin:bench/create-theme-token-normalization
Closed

Improve native createTheme token normalization#489
yaminyassin wants to merge 1 commit into
react:mainfrom
yaminyassin:bench/create-theme-token-normalization

Conversation

@yaminyassin

@yaminyassin yaminyassin commented May 28, 2026

Copy link
Copy Markdown
Contributor

Replace regex in native createTheme token normalization

Summary

Native css.createTheme no longer uses a regex to strip var(-- and ) from tokens returned by css.defineVars. The code now checks for the generated prefix/suffix and slices the token name directly.

This relies on the existing createTheme contract: the first argument is the return value of defineVars. Native defineVars emits tokens as var(--${name}).

Test Plan

  • npm i
  • npm run flow
  • npm test
  • npm run perf --workspace benchmarks
  • npm run size --workspace benchmarks

@meta-cla meta-cla Bot added the cla signed label May 28, 2026
@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown

workflow: benchmarks/perf (native)

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

Results Base Patch Ratio
css.create
· small 1,124,845 1,126,457 1.00 +
· small with units 493,254 493,675 1.00 +
· small with variables 659,923 680,878 1.03 +
· several small 348,172 350,466 1.01 +
· large 198,849 200,280 1.01 +
· large with polyfills 144,989 148,144 1.02 +
· complex 101,282 101,824 1.01 +
· unsupported 209,105 210,971 1.01 +
css.createTheme
· simple theme 228,932 564,245 2.46 !!
· polyfill theme 218,567 527,360 2.41 !!

@github-actions

Copy link
Copy Markdown

workflow: benchmarks/size

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

Results Base Patch Ratio
react-strict-dom/dist/web/index.js
· compressed 3,251 3,251 1.00
· minified 10,375 10,375 1.00
react-strict-dom/dist/web/runtime.js
· compressed 1,645 1,645 1.00
· minified 4,131 4,131 1.00
react-strict-dom/dist/native/index.js
· compressed 16,638 16,636 1.00 -
· minified 64,632 64,653 1.00 +
react-strict-animated/dist/web/index.js
· compressed 6,861 6,861 1.00
· minified 23,486 23,486 1.00
react-strict-animated/dist/native/index.js
· compressed 797 797 1.00
· minified 2,518 2,518 1.00

@yaminyassin yaminyassin force-pushed the bench/create-theme-token-normalization branch from 5b42fa9 to 6ab4a7a Compare May 28, 2026 20:10
@yaminyassin yaminyassin marked this pull request as draft June 2, 2026 20:41
@yaminyassin yaminyassin closed this Jun 2, 2026
@yaminyassin yaminyassin deleted the bench/create-theme-token-normalization branch June 2, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant