mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Moves _some_ files from HIR into new top-level directories. To not make @gsathya's life a pain I left the files he's touching alone, but I moved some others. My intent is to have something like this: * Babel/ - code for the Babel plugin, though ideally this actually gets split into a separate package and the compiler itself is AST in, AST out w no Babel dep. * HIR/ - the core HIRFunction, HIR and related data types, plus the HIR construction and printing, HIR visitors. * Inference/ - the core inference passes that operate on the HIR, including type inference, reference effects, alias analysis, mutable range analysis, etc. I'll let @gsathya move these files when at a good stopping point. * ReactiveScopes/ - inference relating to reactive scopes, constructing/printing/codegenning ReactiveFunction * SSA/ - enter/leave SSA and eliminate redundant phis * Utils/ - every project needs a place to put stuff that doesn't fit into the other categories, this is ours. This leaves just index.ts at the top level, and overall feels pretty tidy. Not too tedious to figure out where anything goes, hopefully.
test262
@ 83a46bfe0e
React Forget
React Forget is an experimental Babel plugin to automatically memoize React Hooks and Components.
Development
# tsc --watch
$ yarn dev
# in another terminal window
$ yarn test --watch
Notes
An overview of the implementation can be found in the Architecture Overview.
This transform
- needs plugin-syntax-jsx as a dependency to inherit the syntax from.
- should be run before plugin-transform-react-jsx
- assume the enforcement of rules of hooks, i.e.
- only call hooks from React functions
- only call hooks at the top level
- https://www.npmjs.com/package/eslint-plugin-react-hooks
Scaffolding
- https://github.com/facebook/flow/tree/master/packages/babel-plugin-transform-flow-enums
- https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts
Reference