Validate options before replacing with compiled function

This commit is contained in:
Sathya Gunasekaran
2023-11-07 11:04:34 +00:00
parent d6ff65ecc7
commit cf70ef899e
@@ -332,18 +332,6 @@ export function compileProgram(
}
}
for (const { originalFn: fn, compiledFn } of compiledFns) {
// Only insert Forget-ified functions if we have not encountered a critical
// error elsewhere in the file, regardless of bailout mode.
insertNewFunctionDeclaration(fn, compiledFn, pass);
hasForgetMutatedOriginalSource = true;
}
// Forget compiled the component, we need to update existing imports of unstable_useMemoCache
if (hasForgetMutatedOriginalSource) {
updateUseMemoCacheImport(program, options);
}
const externalFunctions: ExternalFunction[] = [];
try {
// TODO: check for duplicate import specifiers
@@ -370,6 +358,18 @@ export function compileProgram(
return;
}
// Only insert Forget-ified functions if we have not encountered a critical
// 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) {
updateUseMemoCacheImport(program, options);
}
addImportsToProgram(program, externalFunctions);
}