react/compiler/packages/babel-plugin-react-compiler
Joe Savona 9d7f02d9ab [compiler] General-purpose function outlining
Implements general-purpose function outlining. Specifically, anonymous function expressions which have no dependencies/context variables are extracted into named top-level functions. The original function expression is replaced with a `LoadGlobal` of the generated name.

Note that the architecture is designed to allow very general purpose forms of outlining, though we currently are very conservative in what we outline. Specifically, the outlining allows annotating functions with an optional ReactiveFunctionType, which if set will cause the outlined function to get compiled as that type. So we could for example outline a helper hook or helper component, set the type, and then have the hook/component get memoized as well. For now though we just outline with no type set, and generate the function as-is without running it through compilation.

ghstack-source-id: 2a7da6c8e85c3f8becb22d3869d9b6200f7db126
Pull Request resolved: https://github.com/facebook/react/pull/30331
2024-07-17 10:22:08 +09:00
..
scripts [compiler] General-purpose function outlining 2024-07-17 10:22:08 +09:00
src [compiler] General-purpose function outlining 2024-07-17 10:22:08 +09:00
jest.config.js Rename babel plugin 2024-05-02 14:12:33 -07:00
package.json Bump version to 0.0.0-experimental-696af53-20240625 2024-06-25 12:42:06 -04:00
README.md [compiler] Add readme for babel plugin 2024-05-15 17:29:49 -07:00
rollup.config.js Rename babel plugin 2024-05-02 14:12:33 -07: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