@samitouri / QOS-React-1 / commits / d8734b5136

Remove hasForgetMutatedOriginalSource

Derive it from compiledFns rather than duplicating state

Sathya Gunasekaran committed Nov 7, 2023 at 11:04 UTC d8734b5136363891cfcabdae4bfa9fd6a1c16f00
1 file changed +1 -3
compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts
+1 -3
@@ -242,7 +242,6 @@ export function compileProgram(
242 // have already encountered errors) for reporting.
243 const lintError = findEslintSuppressions(pass.comments);
244 let hasCriticalError = lintError != null;
245 - let hasForgetMutatedOriginalSource: boolean = false;
245 const compiledFns: CompileResult[] = [];
246
247 const traverseFunction = (
@@ -359,11 +358,10 @@ export function compileProgram(
358 // error elsewhere in the file, regardless of bailout mode.
359 for (const { originalFn: fn, compiledFn } of compiledFns) {
360 insertNewFunctionDeclaration(fn, compiledFn, pass);
362 - hasForgetMutatedOriginalSource = true;
361 }
362
363 // Forget compiled the component, we need to update existing imports of unstable_useMemoCache
366 - if (hasForgetMutatedOriginalSource) {
364 + if (compiledFns.length > 0) {
365 updateUseMemoCacheImport(program, options);
366 }
367