mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Compiler playground now runs the entire program through `babel-plugin-react-compiler` instead of a custom pipeline which previously duplicated function inference logic from `Program.ts`. In addition, the playground output reflects the tranformed file (instead of a "virtual file" of manually concatenated functions). This helps with the following: - Reduce potential discrepencies between playground and babel plugin behavior. See attached fixture output for an example where we previously diverged. - Let playground users see compiler-inserted imports (e.g. `_c` or `useFire`) This also helps us repurpose playground into a more general tool for compiler-users instead of just for compiler engineers. - imports and other functions are preserved. We differentiate between imports and globals in many cases (e.g. `inferEffectDeps`), so it may be misleading to omit imports in printed output - playground now shows other program-changing behavior like position of outlined functions and hoisted declarations - emitted compiled functions do not need synthetic names --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31774). * #31809 * __->__ #31774
React Compiler Playground
An interactive playground to demonstrate, test, and have fun with React Compiler.
Setup
# Build React Compiler from source and install Playground dependencies.
$ yarn
# Or similarly
$ npm install
Development
# Start the local development server with
$ yarn dev
# Or
$ npm run dev
# Rerun the following (in a separate terminal window) when React Compiler
# is changed locally to keep Playground in sync.
$ yarn
Testing
# Install playwright browser binaries
$ npx playwright install --with-deps
# Run tests
$ yarn test
Deployment
This project has been deployed using Vercel. Vercel does the exact same thing as we would
locally, by running yarn at the install step in the Playground directory to build
React Compiler from source and symlink it as its dependency.
This means that Playground is automatically deployed on every push and pull requests will reflect
the behaviors of React Compiler of that commit.