Skip to content
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: dev-runtime returns the API instead of patching it #746

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

nmn
Copy link
Contributor

@nmn nmn commented Oct 14, 2024

Update the dev-runtime to return the API instead of relying on patching

This is a fairly simple change that should make it easier to try out StyleX using the dev-runtime package.

Previously, it relied on using a secret __monkney__patch api within Stylex to monkey patch the @stylexjs/stylex package itself. This had many issues, but mainly

  • it would sometimes patch a package that was never loaded in the browser
  • it was difficult to ensure the patching happened before the API was used.

The new solution is that the default export from dev-runtime will be a function that when called with the suitable config, return the StyleX API.

Again, this is only for quick prototyping and testing out the StyleX API. It should never be used in production.

Next step

Update documentation

@facebook-github-bot facebook-github-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 Oct 14, 2024
Copy link

workflow: benchmarks/size

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

@stylexjs/scripts@0.8.0 size:compare
./size-compare.js /tmp/tmp.jrNnmBpmXO /tmp/tmp.SBQeGMcUS7

Results Base Patch Ratio
stylex/lib/stylex.js
· compressed 899 729 0.81 !!
· minified 3,223 2,541 0.79 !!
stylex/lib/StyleXSheet.js
· compressed 1,266 1,266 1.00
· minified 3,776 3,776 1.00
rollup-example/.build/bundle.js
· compressed 563,025 563,025 1.00
· minified 10,185,368 10,185,368 1.00
rollup-example/.build/stylex.css
· compressed 99,154 99,154 1.00
· minified 745,649 745,649 1.00

@nmn nmn merged commit 6771fb6 into main Oct 16, 2024
8 checks passed
@nmn nmn deleted the feat/better-dev-runtime branch October 16, 2024 03:19
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