compiler: only resolve globals and react imports
Updates Environment#getGlobalDeclaration() to only resolve "globals" if they are a true global or an import from react/react-dom. We still keep the logic to resolve hook-like names as custom hooks. Notably, this means that a local `Array` reference won't get confused with our Array global declaration, a local `useState` (or import from something other than React) won't get confused as `React.useState()`, etc. Still working on more tests. ghstack-source-id: 3494c99d0f61570b9a67c3151e01f4204101dacd Pull Request resolved: https://github.com/facebook/react/pull/29190
Showing
- compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts 35 additions, 11 deletions...ckages/babel-plugin-react-compiler/src/HIR/Environment.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts 32 additions, 1 deletion.../packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/globals-dont-resolve-local-useState.expect.md 64 additions, 0 deletions...es/compiler/globals-dont-resolve-local-useState.expect.md
- compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/globals-dont-resolve-local-useState.js 11 additions, 0 deletions.../fixtures/compiler/globals-dont-resolve-local-useState.js
- compiler/packages/snap/src/compiler.ts 1 addition, 0 deletionscompiler/packages/snap/src/compiler.ts
Please register or sign in to comment