Program.ts — react Source File
Architecture documentation for Program.ts, a typescript file in the react codebase. 38 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 9aa4477d_960b_1ea1_b6d9_36076aaa70bd["Program.ts"] e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> e96f281e_f381_272d_2359_3e6a091c9a1d e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> e51fd0d2_bb38_cc97_7763_efe37f300a47 7cb692eb_ba8e_04dc_5f67_df48b332c3c1["CompilerErrorDetail"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> 7cb692eb_ba8e_04dc_5f67_df48b332c3c1 a2b91621_58d3_1d04_4663_00cd808f1034["ErrorCategory"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> a2b91621_58d3_1d04_4663_00cd808f1034 1b971013_8a90_0d8d_1fcc_f31581cd66aa["Environment.ts"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> 1b971013_8a90_0d8d_1fcc_f31581cd66aa 9017c821_3b98_1fe2_6116_790d721b5b40["ExternalFunction"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> 9017c821_3b98_1fe2_6116_790d721b5b40 3d4f48f2_0491_af90_7077_5573865bf9da["ReactFunctionType"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> 3d4f48f2_0491_af90_7077_5573865bf9da 0291e079_1c14_3cf3_45da_30767ab28e42["index.ts"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> 0291e079_1c14_3cf3_45da_30767ab28e42 4d5127e7_7f7a_8639_b8da_3ebfa02a4a0b["ComponentDeclaration.ts"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> 4d5127e7_7f7a_8639_b8da_3ebfa02a4a0b 55caad3b_d237_c12f_6969_e6e7b691d35f["isComponentDeclaration"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> 55caad3b_d237_c12f_6969_e6e7b691d35f 8ea5bb32_7c01_4152_af7d_185ccbdc3e57["HookDeclaration.ts"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> 8ea5bb32_7c01_4152_af7d_185ccbdc3e57 9861537f_51c5_8f2f_5daa_1e82083380d5["isHookDeclaration"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> 9861537f_51c5_8f2f_5daa_1e82083380d5 eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> eb9d33f9_42c1_205c_93e6_8e1365a31839 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> d7fde76c_4fd9_feb3_299b_798689f05bc6 style 9aa4477d_960b_1ea1_b6d9_36076aaa70bd 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 {NodePath} from '@babel/core';
import * as t from '@babel/types';
import {
CompilerError,
CompilerErrorDetail,
ErrorCategory,
} from '../CompilerError';
import {ExternalFunction, ReactFunctionType} from '../HIR/Environment';
import {CodegenFunction} from '../ReactiveScopes';
import {isComponentDeclaration} from '../Utils/ComponentDeclaration';
import {isHookDeclaration} from '../Utils/HookDeclaration';
import {assertExhaustive} from '../Utils/utils';
import {insertGatedFunctionDeclaration} from './Gating';
import {
addImportsToProgram,
ProgramContext,
validateRestrictedImports,
} from './Imports';
import {
CompilerOutputMode,
CompilerReactTarget,
ParsedPluginOptions,
PluginOptions,
} from './Options';
import {compileFn} from './Pipeline';
import {
filterSuppressionsThatAffectFunction,
findProgramSuppressions,
suppressionsToCompilerError,
} from './Suppression';
import {GeneratedSource} from '../HIR';
import {Err, Ok, Result} from '../Utils/Result';
export type CompilerPass = {
opts: ParsedPluginOptions;
filename: string | null;
comments: Array<t.CommentBlock | t.CommentLine>;
code: string | null;
};
export const OPT_IN_DIRECTIVES = new Set(['use forget', 'use memo']);
export const OPT_OUT_DIRECTIVES = new Set(['use no forget', 'use no memo']);
const DYNAMIC_GATING_DIRECTIVE = new RegExp('^use memo if\\(([^\\)]*)\\)$');
export function tryFindDirectiveEnablingMemoization(
directives: Array<t.Directive>,
opts: ParsedPluginOptions,
): Result<t.Directive | null, CompilerError> {
const optIn = directives.find(directive =>
OPT_IN_DIRECTIVES.has(directive.value.value),
);
if (optIn != null) {
return Ok(optIn);
}
// ... (1387 more lines)
Domain
Subdomains
Functions
- applyCompiledFunctions()
- callsHooksOrCreatesJsx()
- compileProgram()
- createNewFunctionNode()
- findDirectiveDisablingMemoization()
- findDirectivesDynamicGating()
- findFunctionsToCompile()
- getComponentOrHookLike()
- getFunctionName()
- getFunctionReferencedBeforeDeclarationAtTopLevel()
- getReactCompilerRuntimeModule()
- getReactFunctionType()
- handleError()
- hasMemoCacheFunctionImport()
- insertNewOutlinedFunctionNode()
- isComponentName()
- isConfigError()
- isError()
- isFilePartOfSources()
- isForwardRefCallback()
- isHook()
- isHookName()
- isMemoCallback()
- isNonNode()
- isReactAPI()
- isValidComponentParams()
- isValidPropsAnnotation()
- logError()
- processFn()
- retryCompileFunction()
- returnsNonNode()
- shouldSkipCompilation()
- skipNestedFunctions()
- tryCompileFunction()
- tryFindDirectiveEnablingMemoization()
- validateNoDynamicallyCreatedComponentsOrHooks()
Dependencies
- CompilerError
- CompilerError.ts
- CompilerErrorDetail
- CompilerOutputMode
- CompilerReactTarget
- ComponentDeclaration.ts
- Environment.ts
- Err
- ErrorCategory
- ExternalFunction
- Gating.ts
- HookDeclaration.ts
- Imports.ts
- Ok
- Options.ts
- ParsedPluginOptions
- Pipeline.ts
- PluginOptions
- ProgramContext
- ReactFunctionType
- Result
- Result.ts
- Suppression.ts
- addImportsToProgram
- assertExhaustive
- compileFn
- core
- filterSuppressionsThatAffectFunction
- findProgramSuppressions
- index.ts
- index.ts
- insertGatedFunctionDeclaration
- isComponentDeclaration
- isHookDeclaration
- suppressionsToCompilerError
- types
- utils.ts
- validateRestrictedImports
Imported By
Source
Frequently Asked Questions
What does Program.ts do?
Program.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in Program.ts?
Program.ts defines 36 function(s): applyCompiledFunctions, callsHooksOrCreatesJsx, compileProgram, createNewFunctionNode, findDirectiveDisablingMemoization, findDirectivesDynamicGating, findFunctionsToCompile, getComponentOrHookLike, getFunctionName, getFunctionReferencedBeforeDeclarationAtTopLevel, and 26 more.
What does Program.ts depend on?
Program.ts imports 38 module(s): CompilerError, CompilerError.ts, CompilerErrorDetail, CompilerOutputMode, CompilerReactTarget, ComponentDeclaration.ts, Environment.ts, Err, and 30 more.
What files import Program.ts?
Program.ts is imported by 2 file(s): Imports.ts, ValidateNoUntransformedReferences.ts.
Where is Program.ts in the architecture?
Program.ts is located at compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts (domain: BabelCompiler, subdomain: Entrypoint, directory: compiler/packages/babel-plugin-react-compiler/src/Entrypoint).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free