Home / Function/ build() — react Function Reference

build() — react Function Reference

Architecture documentation for the build() function in HIRBuilder.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391["build()"]
  d1b85268_f4cd_bc3c_7ba0_ee15dcc8a845["HIRBuilder"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|defined in| d1b85268_f4cd_bc3c_7ba0_ee15dcc8a845
  f214c28b_2f6d_b5a3_71e1_9a69d9b50455["lower()"]
  f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| 5dec5bb8_e0f9_d79d_1c1d_65a05ff57391
  30907c46_684f_39cf_12ac_900130b902f4["buildDependencyInstructions()"]
  30907c46_684f_39cf_12ac_900130b902f4 -->|calls| 5dec5bb8_e0f9_d79d_1c1d_65a05ff57391
  7833545a_a3bd_6148_f79c_09179baa11a3["getReversePostorderedBlocks()"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|calls| 7833545a_a3bd_6148_f79c_09179baa11a3
  cf8d627e_c2f0_6cd4_e5fc_35f3c7005b64["throwTodo()"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|calls| cf8d627e_c2f0_6cd4_e5fc_35f3c7005b64
  4fd451a9_a7fd_9520_07fd_783e18d24c84["removeUnreachableForUpdates()"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|calls| 4fd451a9_a7fd_9520_07fd_783e18d24c84
  ba25d103_adb3_8e17_0348_cdf4b23496b5["removeDeadDoWhileStatements()"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|calls| ba25d103_adb3_8e17_0348_cdf4b23496b5
  c678dac0_f0b5_fd43_e8fe_97067c37de7d["removeUnnecessaryTryCatch()"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|calls| c678dac0_f0b5_fd43_e8fe_97067c37de7d
  0c09df5a_6c07_11e5_1a6b_9253007463b8["markInstructionIds()"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|calls| 0c09df5a_6c07_11e5_1a6b_9253007463b8
  6d209f7d_6d38_4dee_c66c_76af0358f508["markPredecessors()"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|calls| 6d209f7d_6d38_4dee_c66c_76af0358f508
  style 5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts lines 371–401

  build(): HIR {
    let ir: HIR = {
      blocks: this.#completed,
      entry: this.#entry,
    };
    const rpoBlocks = getReversePostorderedBlocks(ir);
    for (const [id, block] of ir.blocks) {
      if (
        !rpoBlocks.has(id) &&
        block.instructions.some(
          instr => instr.value.kind === 'FunctionExpression',
        )
      ) {
        CompilerError.throwTodo({
          reason: `Support functions with unreachable code that may contain hoisted declarations`,
          loc: block.instructions[0]?.loc ?? block.terminal.loc,
          description: null,
          suggestions: null,
        });
      }
    }
    ir.blocks = rpoBlocks;

    removeUnreachableForUpdates(ir);
    removeDeadDoWhileStatements(ir);
    removeUnnecessaryTryCatch(ir);
    markInstructionIds(ir);
    markPredecessors(ir);

    return ir;
  }

Subdomains

Frequently Asked Questions

What does build() do?
build() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts.
Where is build() defined?
build() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts at line 371.
What does build() call?
build() calls 7 function(s): getReversePostorderedBlocks, markInstructionIds, markPredecessors, removeDeadDoWhileStatements, removeUnnecessaryTryCatch, removeUnreachableForUpdates, throwTodo.
What calls build()?
build() is called by 2 function(s): buildDependencyInstructions, lower.

Analyze Your Own Codebase

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

Try Supermodel Free