From d8734b5136363891cfcabdae4bfa9fd6a1c16f00 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Tue, 7 Nov 2023 11:04:35 +0000 Subject: [PATCH] Remove hasForgetMutatedOriginalSource Derive it from compiledFns rather than duplicating state --- .../babel-plugin-react-forget/src/Entrypoint/Program.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts index b4dfec948b..189cf4d19b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts @@ -242,7 +242,6 @@ export function compileProgram( // have already encountered errors) for reporting. const lintError = findEslintSuppressions(pass.comments); let hasCriticalError = lintError != null; - let hasForgetMutatedOriginalSource: boolean = false; const compiledFns: CompileResult[] = []; const traverseFunction = ( @@ -359,11 +358,10 @@ export function compileProgram( // error elsewhere in the file, regardless of bailout mode. for (const { originalFn: fn, compiledFn } of compiledFns) { insertNewFunctionDeclaration(fn, compiledFn, pass); - hasForgetMutatedOriginalSource = true; } // Forget compiled the component, we need to update existing imports of unstable_useMemoCache - if (hasForgetMutatedOriginalSource) { + if (compiledFns.length > 0) { updateUseMemoCacheImport(program, options); }