Home / Function/ runWithEnvironment() — react Function Reference

runWithEnvironment() — react Function Reference

Architecture documentation for the runWithEnvironment() function in Pipeline.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb["runWithEnvironment()"]
  e3cfc07a_10c8_5dcd_e270_e8e14c29309b["Pipeline.ts"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|defined in| e3cfc07a_10c8_5dcd_e270_e8e14c29309b
  9e9f9b6d_740c_69bf_979d_bba888d70105["run()"]
  9e9f9b6d_740c_69bf_979d_bba888d70105 -->|calls| c3bc3875_256f_8f5e_7800_2f9c5bae65eb
  d3225c91_4858_fca4_72c5_c74a4f05f299["lowerContextAccess()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| d3225c91_4858_fca4_72c5_c74a4f05f299
  7fa40de0_6c03_ccf5_ce80_c1bfabcc2181["optimizePropsMethodCalls()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 7fa40de0_6c03_ccf5_ce80_c1bfabcc2181
  1f2853c7_05e1_f3c4_b9d5_1f5ca0f648ea["inferMutationAliasingEffects()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 1f2853c7_05e1_f3c4_b9d5_1f5ca0f648ea
  93674d7a_a49c_dadd_0d67_6c5e98450587["optimizeForSSR()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 93674d7a_a49c_dadd_0d67_6c5e98450587
  06363a0e_405c_bfba_71c1_808efa86a089["instructionReordering()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 06363a0e_405c_bfba_71c1_808efa86a089
  f3815d1a_36a1_3e3d_92f2_dbbe88f01fe3["inferMutationAliasingRanges()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| f3815d1a_36a1_3e3d_92f2_dbbe88f01fe3
  42a1b6ad_eddb_6bd3_4831_1d199766f971["validateLocalsNotReassignedAfterRender()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 42a1b6ad_eddb_6bd3_4831_1d199766f971
  702fa0b8_ba8c_390e_cde1_4dca39712628["logErrors()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 702fa0b8_ba8c_390e_cde1_4dca39712628
  f9f36408_8e51_961b_c26d_24ee285bd479["validateNoDerivedComputationsInEffects_exp()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| f9f36408_8e51_961b_c26d_24ee285bd479
  1d91b2b6_6806_f495_0567_ab13bf567e33["validateNoDerivedComputationsInEffects()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 1d91b2b6_6806_f495_0567_ab13bf567e33
  9122e965_d8f6_df86_dd39_3a5721b58d49["validateNoSetStateInEffects()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 9122e965_d8f6_df86_dd39_3a5721b58d49
  098764b0_1542_854b_0a71_e361ec33cef2["validateNoJSXInTryStatement()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 098764b0_1542_854b_0a71_e361ec33cef2
  style c3bc3875_256f_8f5e_7800_2f9c5bae65eb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts lines 154–598

function runWithEnvironment(
  func: NodePath<
    t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression
  >,
  env: Environment,
): CodegenFunction {
  const log = (value: CompilerPipelineValue): void => {
    env.logger?.debugLogIRs?.(value);
  };
  const hir = lower(func, env).unwrap();
  log({kind: 'hir', name: 'HIR', value: hir});

  pruneMaybeThrows(hir);
  log({kind: 'hir', name: 'PruneMaybeThrows', value: hir});

  validateContextVariableLValues(hir);
  validateUseMemo(hir).unwrap();

  if (
    env.enableDropManualMemoization &&
    !env.config.enablePreserveExistingManualUseMemo &&
    !env.config.disableMemoizationForDebugging &&
    !env.config.enableChangeDetectionForDebugging
  ) {
    dropManualMemoization(hir).unwrap();
    log({kind: 'hir', name: 'DropManualMemoization', value: hir});
  }

  inlineImmediatelyInvokedFunctionExpressions(hir);
  log({
    kind: 'hir',
    name: 'InlineImmediatelyInvokedFunctionExpressions',
    value: hir,
  });

  mergeConsecutiveBlocks(hir);
  log({kind: 'hir', name: 'MergeConsecutiveBlocks', value: hir});

  assertConsistentIdentifiers(hir);
  assertTerminalSuccessorsExist(hir);

  enterSSA(hir);
  log({kind: 'hir', name: 'SSA', value: hir});

  eliminateRedundantPhi(hir);
  log({kind: 'hir', name: 'EliminateRedundantPhi', value: hir});

  assertConsistentIdentifiers(hir);

  constantPropagation(hir);
  log({kind: 'hir', name: 'ConstantPropagation', value: hir});

  inferTypes(hir);
  log({kind: 'hir', name: 'InferTypes', value: hir});

  if (env.enableValidations) {
    if (env.config.validateHooksUsage) {
      validateHooksUsage(hir).unwrap();
    }
    if (env.config.validateNoCapitalizedCalls) {
      validateNoCapitalizedCalls(hir).unwrap();
    }
  }

  if (env.config.enableFire) {
    transformFire(hir);
    log({kind: 'hir', name: 'TransformFire', value: hir});
  }

  if (env.config.lowerContextAccess) {
    lowerContextAccess(hir, env.config.lowerContextAccess);
  }

  optimizePropsMethodCalls(hir);
  log({kind: 'hir', name: 'OptimizePropsMethodCalls', value: hir});

  analyseFunctions(hir);
  log({kind: 'hir', name: 'AnalyseFunctions', value: hir});

  const mutabilityAliasingErrors = inferMutationAliasingEffects(hir);
  log({kind: 'hir', name: 'InferMutationAliasingEffects', value: hir});

Domain

Subdomains

Called By

Frequently Asked Questions

What does runWithEnvironment() do?
runWithEnvironment() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts.
Where is runWithEnvironment() defined?
runWithEnvironment() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts at line 154.
What does runWithEnvironment() call?
runWithEnvironment() calls 28 function(s): alignMethodCallScopes, alignReactiveScopesToBlockScopesHIR, flattenReactiveLoopsHIR, flattenScopesWithHooksOrUseHIR, inferMutationAliasingEffects, inferMutationAliasingRanges, instructionReordering, logErrors, and 20 more.
What calls runWithEnvironment()?
runWithEnvironment() is called by 1 function(s): run.

Analyze Your Own Codebase

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

Try Supermodel Free