react/compiler/packages/babel-plugin-react-compiler
mofeiZ a78bbf9dbc
[compiler] Context variables as dependencies (#31582)
We previously didn't track context variables in the hoistable values
sidemap of `propagateScopeDependencies`. This was overly conservative as
we *do* track the mutable range of context variables, and it is safe to
hoist accesses to context variables after their last direct / aliased
maybe-assignment.

```js
function Component({value}) {
  // start of mutable range for `x`
  let x = DEFAULT;
  const setX = () => x = value;
  const aliasedSet = maybeAlias(setX);
  maybeCall(aliasedSet);
  // end of mutable range for `x`

  // here, we should be able to take x (and property reads
  // off of x) as dependencies
  return <Jsx value={x} />
}
```
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31582).
* #31583
* __->__ #31582
2024-12-16 16:45:05 -05:00
..
scripts [rcr] Update default runtimeModule to react-compiler-runtime (#31144) 2024-10-07 17:59:33 -04:00
src [compiler] Context variables as dependencies (#31582) 2024-12-16 16:45:05 -05:00
jest.config.js Compiler: unfork prettier config (#30205) 2024-07-18 17:00:24 -04:00
package.json [compiler][be] Logger based debug printing in test runner (#31809) 2024-12-16 15:15:13 -05:00
README.md [compiler] Add readme for babel plugin 2024-05-15 17:29:49 -07:00
rollup.config.js [compiler] Disable emit of .tsbuildinfo (#31459) 2024-11-14 15:43:36 -05:00
tsconfig.json Don't emit types for babel-plugin-react-compiler 2024-05-14 11:02:30 -04:00

babel-plugin-react-compiler

React Compiler is a compiler that optimizes React applications, ensuring that only the minimal parts of components and hooks will re-render when state changes. The compiler also validates that components and hooks follow the Rules of React.

This package contains the React Compiler Babel plugin use in projects that make use of Babel. You can find instructions for using this plugin here: https://react.dev/learn/react-compiler