Home / Function/ tryCompileFunction() — react Function Reference

tryCompileFunction() — react Function Reference

Architecture documentation for the tryCompileFunction() function in Program.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  b463b9d1_ce95_79dd_d7b2_7be04016ee66["tryCompileFunction()"]
  9aa4477d_960b_1ea1_b6d9_36076aaa70bd["Program.ts"]
  b463b9d1_ce95_79dd_d7b2_7be04016ee66 -->|defined in| 9aa4477d_960b_1ea1_b6d9_36076aaa70bd
  db0bec13_2016_3880_d2b9_adcd797cdf2c["processFn()"]
  db0bec13_2016_3880_d2b9_adcd797cdf2c -->|calls| b463b9d1_ce95_79dd_d7b2_7be04016ee66
  3ac0dd32_072d_54e2_705d_585cc3f9db16["filterSuppressionsThatAffectFunction()"]
  b463b9d1_ce95_79dd_d7b2_7be04016ee66 -->|calls| 3ac0dd32_072d_54e2_705d_585cc3f9db16
  d31deb45_fb36_194b_4bb5_e81a98b6c9bd["suppressionsToCompilerError()"]
  b463b9d1_ce95_79dd_d7b2_7be04016ee66 -->|calls| d31deb45_fb36_194b_4bb5_e81a98b6c9bd
  a086c126_7bb9_8c77_d2a2_e8336faecc5b["compileFn()"]
  b463b9d1_ce95_79dd_d7b2_7be04016ee66 -->|calls| a086c126_7bb9_8c77_d2a2_e8336faecc5b
  style b463b9d1_ce95_79dd_d7b2_7be04016ee66 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts lines 706–747

function tryCompileFunction(
  fn: BabelFn,
  fnType: ReactFunctionType,
  programContext: ProgramContext,
  outputMode: CompilerOutputMode,
):
  | {kind: 'compile'; compiledFn: CodegenFunction}
  | {kind: 'error'; error: unknown} {
  /**
   * Note that Babel does not attach comment nodes to nodes; they are dangling off of the
   * Program node itself. We need to figure out whether an eslint suppression range
   * applies to this function first.
   */
  const suppressionsInFunction = filterSuppressionsThatAffectFunction(
    programContext.suppressions,
    fn,
  );
  if (suppressionsInFunction.length > 0) {
    return {
      kind: 'error',
      error: suppressionsToCompilerError(suppressionsInFunction),
    };
  }

  try {
    return {
      kind: 'compile',
      compiledFn: compileFn(
        fn,
        programContext.opts.environment,
        fnType,
        outputMode,
        programContext,
        programContext.opts.logger,
        programContext.filename,
        programContext.code,
      ),
    };
  } catch (err) {
    return {kind: 'error', error: err};
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does tryCompileFunction() do?
tryCompileFunction() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts.
Where is tryCompileFunction() defined?
tryCompileFunction() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts at line 706.
What does tryCompileFunction() call?
tryCompileFunction() calls 3 function(s): compileFn, filterSuppressionsThatAffectFunction, suppressionsToCompilerError.
What calls tryCompileFunction()?
tryCompileFunction() is called by 1 function(s): processFn.

Analyze Your Own Codebase

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

Try Supermodel Free