mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Validate options before replacing with compiled function
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user