dillon1000/react

Commit

[compiler][be] Playground now compiles entire program (#31774)

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
Browse files
Changed paths20 files
First-parent comparison
M compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/01-user-output.txt ModifiedM compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/02-default-output.txt ModifiedM compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/module-scope-use-memo-output.txt ModifiedM compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/module-scope-use-no-memo-output.txt ModifiedA compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/parse-flow-output.txt AddedA compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/parse-typescript-output.txt AddedA compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/todo-function-scope-does-not-beat-module-scope-output.txt AddedM compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/use-memo-output.txt ModifiedM compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/use-no-memo-output.txt ModifiedM compiler/apps/playground/__tests__/e2e/page.spec.ts ModifiedM compiler/apps/playground/components/Editor/EditorImpl.tsx ModifiedM compiler/apps/playground/components/Editor/Output.tsx ModifiedM compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts ModifiedM compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts ModifiedM compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts ModifiedM compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts ModifiedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-no-memo-module-scope-usememo-function-scope.expect.md AddedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-no-memo-module-scope-usememo-function-scope.js AddedM compiler/packages/babel-plugin-react-compiler/src/__tests__/parseConfigPragma-test.ts ModifiedM compiler/packages/babel-plugin-react-compiler/src/index.ts Modified
Patch

Files changed

Rendering syntax-highlighted changes…