PruneNonEscapingScopes.ts — react Source File
Architecture documentation for PruneNonEscapingScopes.ts, a typescript file in the react codebase. 19 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c4112963_95fe_d8ed_3bfd_f6d45887acb7["PruneNonEscapingScopes.ts"] e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> e96f281e_f381_272d_2359_3e6a091c9a1d e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> e51fd0d2_bb38_cc97_7763_efe37f300a47 0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> 0423f759_97e0_9101_4634_ed555abc5ca9 eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> eb9d33f9_42c1_205c_93e6_8e1365a31839 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> d7fde76c_4fd9_feb3_299b_798689f05bc6 14f2e51a_d755_814e_2f56_72d3ed119459["getOrInsertDefault"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> 14f2e51a_d755_814e_2f56_72d3ed119459 18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> 18a78965_f593_105b_e5e8_07001321c2ec 7107ba22_4065_0956_1ec3_286f637d0d22["getPlaceScope"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> 7107ba22_4065_0956_1ec3_286f637d0d22 ca9a6820_460e_0b15_8169_3aa4c6503770["ReactiveScope"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> ca9a6820_460e_0b15_8169_3aa4c6503770 21609915_b03a_fd75_b58a_4cb86ef9315b["visitors.ts"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> 21609915_b03a_fd75_b58a_4cb86ef9315b af3ace55_db6d_865e_92b9_81486f6af1e7["ReactiveFunctionTransform"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> af3ace55_db6d_865e_92b9_81486f6af1e7 171a5d22_bb6b_1c99_05a4_6ad897438a35["ReactiveFunctionVisitor"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> 171a5d22_bb6b_1c99_05a4_6ad897438a35 da7ad665_d709_433d_facd_dc3b2c4d34f5["Transformed"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> da7ad665_d709_433d_facd_dc3b2c4d34f5 eadd4103_8b1c_576b_7add_97a5c5edb9c7["eachReactiveValueOperand"] c4112963_95fe_d8ed_3bfd_f6d45887acb7 --> eadd4103_8b1c_576b_7add_97a5c5edb9c7 style c4112963_95fe_d8ed_3bfd_f6d45887acb7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {CompilerError} from '../CompilerError';
import {
DeclarationId,
Environment,
GeneratedSource,
Identifier,
InstructionId,
Pattern,
Place,
ReactiveFunction,
ReactiveInstruction,
ReactiveScopeBlock,
ReactiveStatement,
ReactiveTerminal,
ReactiveTerminalStatement,
ReactiveValue,
ScopeId,
getHookKind,
isMutableEffect,
} from '../HIR';
import {assertExhaustive, getOrInsertDefault} from '../Utils/utils';
import {getPlaceScope, ReactiveScope} from '../HIR/HIR';
import {
ReactiveFunctionTransform,
ReactiveFunctionVisitor,
Transformed,
eachReactiveValueOperand,
visitReactiveFunction,
} from './visitors';
import {printPlace} from '../HIR/PrintHIR';
import {getFunctionCallSignature} from '../Inference/InferMutationAliasingEffects';
/*
* This pass prunes reactive scopes that are not necessary to bound downstream computation.
* Specifically, the pass identifies the set of identifiers which may "escape". Values can
* escape in one of two ways:
* * They are directly returned by the function and/or transitively aliased by a return
* value.
* * They are passed as input to a hook. This is because any value passed to a hook may
* have its referenced ultimately stored by React (ie, be aliased by an external value).
* For example, the closure passed to useEffect escapes.
*
* Example to build intuition:
*
* ```javascript
* function Component(props) {
* const a = {}; // not aliased or returned: *not* memoized
* const b = {}; // aliased by c, which is returned: memoized
* const c = [b]; // directly returned: memoized
* return c;
* }
* ```
*
// ... (1064 more lines)
Domain
Subdomains
Dependencies
- CompilerError
- CompilerError.ts
- HIR.ts
- InferMutationAliasingEffects.ts
- PrintHIR.ts
- ReactiveFunctionTransform
- ReactiveFunctionVisitor
- ReactiveScope
- Transformed
- assertExhaustive
- eachReactiveValueOperand
- getFunctionCallSignature
- getOrInsertDefault
- getPlaceScope
- index.ts
- printPlace
- utils.ts
- visitReactiveFunction
- visitors.ts
Source
Frequently Asked Questions
What does PruneNonEscapingScopes.ts do?
PruneNonEscapingScopes.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in PruneNonEscapingScopes.ts?
PruneNonEscapingScopes.ts defines 4 function(s): computeMemoizedIdentifiers, computePatternLValues, joinAliases, pruneNonEscapingScopes.
What does PruneNonEscapingScopes.ts depend on?
PruneNonEscapingScopes.ts imports 19 module(s): CompilerError, CompilerError.ts, HIR.ts, InferMutationAliasingEffects.ts, PrintHIR.ts, ReactiveFunctionTransform, ReactiveFunctionVisitor, ReactiveScope, and 11 more.
Where is PruneNonEscapingScopes.ts in the architecture?
PruneNonEscapingScopes.ts is located at compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free