applyCompiledFunctions() — react Function Reference
Architecture documentation for the applyCompiledFunctions() function in Program.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 11c511ca_2971_a23f_cfd6_2897f2fe1b13["applyCompiledFunctions()"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd["Program.ts"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|defined in| 9aa4477d_960b_1ea1_b6d9_36076aaa70bd 1c9af54b_10e9_8985_e772_1f517e46c560["compileProgram()"] 1c9af54b_10e9_8985_e772_1f517e46c560 -->|calls| 11c511ca_2971_a23f_cfd6_2897f2fe1b13 1e86a202_a347_7857_88d3_50b0dc42a045["createNewFunctionNode()"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| 1e86a202_a347_7857_88d3_50b0dc42a045 eeae9a52_a6ca_1fc5_b5ef_49075de37df1["findDirectivesDynamicGating()"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| eeae9a52_a6ca_1fc5_b5ef_49075de37df1 58e83968_5fd8_9e9f_e4be_1f50e95f54dc["getFunctionReferencedBeforeDeclarationAtTopLevel()"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| 58e83968_5fd8_9e9f_e4be_1f50e95f54dc 77b776cd_a7c8_1d29_ba32_e5a39fa85dd9["insertGatedFunctionDeclaration()"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| 77b776cd_a7c8_1d29_ba32_e5a39fa85dd9 e19f561e_cb2d_6161_2ab6_1c6533ed4958["addImportsToProgram()"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| e19f561e_cb2d_6161_2ab6_1c6533ed4958 46bdf8e6_4a50_0326_ba9a_f74ee3cfc291["isOk()"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| 46bdf8e6_4a50_0326_ba9a_f74ee3cfc291 5228ee8c_dc7c_d859_3f41_614fd9c00374["unwrap()"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| 5228ee8c_dc7c_d859_3f41_614fd9c00374 style 11c511ca_2971_a23f_cfd6_2897f2fe1b13 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts lines 799–841
function applyCompiledFunctions(
program: NodePath<t.Program>,
compiledFns: Array<CompileResult>,
pass: CompilerPass,
programContext: ProgramContext,
): void {
let referencedBeforeDeclared = null;
for (const result of compiledFns) {
const {kind, originalFn, compiledFn} = result;
const transformedFn = createNewFunctionNode(originalFn, compiledFn);
programContext.alreadyCompiled.add(transformedFn);
let dynamicGating: ExternalFunction | null = null;
if (originalFn.node.body.type === 'BlockStatement') {
const result = findDirectivesDynamicGating(
originalFn.node.body.directives,
pass.opts,
);
if (result.isOk()) {
dynamicGating = result.unwrap()?.gating ?? null;
}
}
const functionGating = dynamicGating ?? pass.opts.gating;
if (kind === 'original' && functionGating != null) {
referencedBeforeDeclared ??=
getFunctionReferencedBeforeDeclarationAtTopLevel(program, compiledFns);
insertGatedFunctionDeclaration(
originalFn,
transformedFn,
programContext,
functionGating,
referencedBeforeDeclared.has(result),
);
} else {
originalFn.replaceWith(transformedFn);
}
}
// Forget compiled the component, we need to update existing imports of useMemoCache
if (compiledFns.length > 0) {
addImportsToProgram(program, programContext);
}
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does applyCompiledFunctions() do?
applyCompiledFunctions() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts.
Where is applyCompiledFunctions() defined?
applyCompiledFunctions() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts at line 799.
What does applyCompiledFunctions() call?
applyCompiledFunctions() calls 7 function(s): addImportsToProgram, createNewFunctionNode, findDirectivesDynamicGating, getFunctionReferencedBeforeDeclarationAtTopLevel, insertGatedFunctionDeclaration, isOk, unwrap.
What calls applyCompiledFunctions()?
applyCompiledFunctions() is called by 1 function(s): compileProgram.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free