Home / Function/ outlineFunctions() — react Function Reference

outlineFunctions() — react Function Reference

Architecture documentation for the outlineFunctions() function in OutlineFunctions.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  a6579cdb_2887_9b1b_8031_f36729701a37["outlineFunctions()"]
  6b95b3b7_7b72_e9ac_0e48_627f5cf18afd["OutlineFunctions.ts"]
  a6579cdb_2887_9b1b_8031_f36729701a37 -->|defined in| 6b95b3b7_7b72_e9ac_0e48_627f5cf18afd
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb["runWithEnvironment()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| a6579cdb_2887_9b1b_8031_f36729701a37
  style a6579cdb_2887_9b1b_8031_f36729701a37 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Optimization/OutlineFunctions.ts lines 10–51

export function outlineFunctions(
  fn: HIRFunction,
  fbtOperands: Set<IdentifierId>,
): void {
  for (const [, block] of fn.body.blocks) {
    for (const instr of block.instructions) {
      const {value, lvalue} = instr;

      if (
        value.kind === 'FunctionExpression' ||
        value.kind === 'ObjectMethod'
      ) {
        // Recurse in case there are inner functions which can be outlined
        outlineFunctions(value.loweredFunc.func, fbtOperands);
      }
      if (
        value.kind === 'FunctionExpression' &&
        value.loweredFunc.func.context.length === 0 &&
        // TODO: handle outlining named functions
        value.loweredFunc.func.id === null &&
        !fbtOperands.has(lvalue.identifier.id)
      ) {
        const loweredFunc = value.loweredFunc.func;

        const id = fn.env.generateGloballyUniqueIdentifierName(
          loweredFunc.id ?? loweredFunc.nameHint,
        );
        loweredFunc.id = id.value;

        fn.env.outlineFunction(loweredFunc, null);
        instr.value = {
          kind: 'LoadGlobal',
          binding: {
            kind: 'Global',
            name: id.value,
          },
          loc: value.loc,
        };
      }
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does outlineFunctions() do?
outlineFunctions() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/OutlineFunctions.ts.
Where is outlineFunctions() defined?
outlineFunctions() is defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/OutlineFunctions.ts at line 10.
What calls outlineFunctions()?
outlineFunctions() is called by 1 function(s): runWithEnvironment.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free