diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts index 762f1a4112ab0..02987fbfc63e5 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts @@ -117,6 +117,7 @@ export function* run( ): Generator { const contextIdentifiers = findContextIdentifiers(func); const env = new Environment( + func.scope, fnType, config, contextIdentifiers, diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts index 277921d5e25ee..c96d545e705f5 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts @@ -41,6 +41,7 @@ import { ShapeRegistry, addHook, } from "./ObjectShape"; +import { Scope as BabelScope } from "@babel/traverse"; export const ExternalFunctionSchema = z.object({ // Source for the imported module that exports the `importSpecifierName` functions @@ -504,6 +505,7 @@ export class Environment { #nextIdentifer: number = 0; #nextBlock: number = 0; #nextScope: number = 0; + #scope: BabelScope; logger: Logger | null; filename: string | null; code: string | null; @@ -515,6 +517,7 @@ export class Environment { #hoistedIdentifiers: Set; constructor( + scope: BabelScope, fnType: ReactFunctionType, config: EnvironmentConfig, contextIdentifiers: Set, @@ -523,6 +526,7 @@ export class Environment { code: string | null, useMemoCacheIdentifier: string ) { + this.#scope = scope; this.fnType = fnType; this.config = config; this.filename = filename;