Home / Function/ inferMinimalDependencies() — react Function Reference

inferMinimalDependencies() — react Function Reference

Architecture documentation for the inferMinimalDependencies() function in InferEffectDependencies.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ca434b67_031d_2bec_f10c_3b8a790002ed["inferMinimalDependencies()"]
  3393f920_76eb_7dd5_b95f_ab92de6cecce["InferEffectDependencies.ts"]
  ca434b67_031d_2bec_f10c_3b8a790002ed -->|defined in| 3393f920_76eb_7dd5_b95f_ab92de6cecce
  3522f83b_2dff_3c9f_920f_3e428eb62b31["inferEffectDependencies()"]
  3522f83b_2dff_3c9f_920f_3e428eb62b31 -->|calls| ca434b67_031d_2bec_f10c_3b8a790002ed
  5c398df4_9a90_b7aa_6be6_ddff9be0b519["collectTemporariesSidemap()"]
  ca434b67_031d_2bec_f10c_3b8a790002ed -->|calls| 5c398df4_9a90_b7aa_6be6_ddff9be0b519
  ef81e884_f545_95f9_d420_7fcb2bd33ee0["collectOptionalChainSidemap()"]
  ca434b67_031d_2bec_f10c_3b8a790002ed -->|calls| ef81e884_f545_95f9_d420_7fcb2bd33ee0
  bdf8cdce_736e_1a2d_6a67_5dacbcb1d645["collectHoistablePropertyLoadsInInnerFn()"]
  ca434b67_031d_2bec_f10c_3b8a790002ed -->|calls| bdf8cdce_736e_1a2d_6a67_5dacbcb1d645
  f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5["inferDependencies()"]
  ca434b67_031d_2bec_f10c_3b8a790002ed -->|calls| f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5
  61f036d0_eb91_7e31_154e_acb3c7c8f23c["addDependency()"]
  ca434b67_031d_2bec_f10c_3b8a790002ed -->|calls| 61f036d0_eb91_7e31_154e_acb3c7c8f23c
  3007052f_a4b8_b5ea_a419_9f2abc9f4286["deriveMinimalDependencies()"]
  ca434b67_031d_2bec_f10c_3b8a790002ed -->|calls| 3007052f_a4b8_b5ea_a419_9f2abc9f4286
  style ca434b67_031d_2bec_f10c_3b8a790002ed fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts lines 548–586

function inferMinimalDependencies(
  fnInstr: TInstruction<FunctionExpression>,
): Set<ReactiveScopeDependency> {
  const fn = fnInstr.value.loweredFunc.func;

  const temporaries = collectTemporariesSidemap(fn, new Set());
  const {
    hoistableObjects,
    processedInstrsInOptional,
    temporariesReadInOptional,
  } = collectOptionalChainSidemap(fn);

  const hoistablePropertyLoads = collectHoistablePropertyLoadsInInnerFn(
    fnInstr,
    temporaries,
    hoistableObjects,
  );
  const hoistableToFnEntry = hoistablePropertyLoads.get(fn.body.entry);
  CompilerError.invariant(hoistableToFnEntry != null, {
    reason:
      '[InferEffectDependencies] Internal invariant broken: missing entry block',
    loc: fnInstr.loc,
  });

  const dependencies = inferDependencies(
    fnInstr,
    new Map([...temporaries, ...temporariesReadInOptional]),
    processedInstrsInOptional,
  );

  const tree = new ReactiveScopeDependencyTreeHIR(
    [...hoistableToFnEntry.assumedNonNullObjects].map(o => o.fullPath),
  );
  for (const dep of dependencies) {
    tree.addDependency({...dep});
  }

  return tree.deriveMinimalDependencies();
}

Domain

Subdomains

Frequently Asked Questions

What does inferMinimalDependencies() do?
inferMinimalDependencies() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts.
Where is inferMinimalDependencies() defined?
inferMinimalDependencies() is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts at line 548.
What does inferMinimalDependencies() call?
inferMinimalDependencies() calls 6 function(s): addDependency, collectHoistablePropertyLoadsInInnerFn, collectOptionalChainSidemap, collectTemporariesSidemap, deriveMinimalDependencies, inferDependencies.
What calls inferMinimalDependencies()?
inferMinimalDependencies() is called by 1 function(s): inferEffectDependencies.

Analyze Your Own Codebase

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

Try Supermodel Free