minimize.ts — react Source File
Architecture documentation for minimize.ts, a typescript file in the react codebase. 7 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 9c061da8_dbf8_4168_823d_991654a3c55d["minimize.ts"] 4eb05026_580f_5088_4e41_961dd36a8f38["./compiler.js"] 9c061da8_dbf8_4168_823d_991654a3c55d --> 4eb05026_580f_5088_4e41_961dd36a8f38 a7aab54c_cd5e_e41a_0d84_e00aa6858cea["./constants.js"] 9c061da8_dbf8_4168_823d_991654a3c55d --> a7aab54c_cd5e_e41a_0d84_e00aa6858cea 102f7d62_f771_0080_dd43_d867f5a8bd55["core"] 9c061da8_dbf8_4168_823d_991654a3c55d --> 102f7d62_f771_0080_dd43_d867f5a8bd55 a864ce16_7fd8_31df_9608_80bee15a50ce["generator"] 9c061da8_dbf8_4168_823d_991654a3c55d --> a864ce16_7fd8_31df_9608_80bee15a50ce ceff537f_04b5_ea96_fed3_19a0a7315bc6["traverse"] 9c061da8_dbf8_4168_823d_991654a3c55d --> ceff537f_04b5_ea96_fed3_19a0a7315bc6 52e3d8d7_abf4_7343_1f98_3f701ec04082["types"] 9c061da8_dbf8_4168_823d_991654a3c55d --> 52e3d8d7_abf4_7343_1f98_3f701ec04082 4981ed31_eed2_3019_b790_fd237d28f366["TestUtils"] 9c061da8_dbf8_4168_823d_991654a3c55d --> 4981ed31_eed2_3019_b790_fd237d28f366 1fd49604_fb16_2568_4971_9eca12fd6a73["runner.ts"] 1fd49604_fb16_2568_4971_9eca12fd6a73 --> 9c061da8_dbf8_4168_823d_991654a3c55d style 9c061da8_dbf8_4168_823d_991654a3c55d 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 type {PluginObj} from '@babel/core';
import {transformFromAstSync} from '@babel/core';
import generate from '@babel/generator';
import traverse from '@babel/traverse';
import * as t from '@babel/types';
import type {parseConfigPragmaForTests as ParseConfigPragma} from 'babel-plugin-react-compiler/src/Utils/TestUtils';
import {parseInput} from './compiler.js';
import {PARSE_CONFIG_PRAGMA_IMPORT, BABEL_PLUGIN_SRC} from './constants.js';
type CompileSuccess = {kind: 'success'};
type CompileParseError = {kind: 'parse_error'; message: string};
type CompileErrors = {
kind: 'errors';
errors: Array<{category: string; reason: string; description: string | null}>;
};
type CompileResult = CompileSuccess | CompileParseError | CompileErrors;
/**
* Compile code and extract error information
*/
function compileAndGetError(
code: string,
filename: string,
language: 'flow' | 'typescript',
sourceType: 'module' | 'script',
plugin: PluginObj,
parseConfigPragmaFn: typeof ParseConfigPragma,
): CompileResult {
let ast: t.File;
try {
ast = parseInput(code, filename, language, sourceType);
} catch (e: unknown) {
return {kind: 'parse_error', message: (e as Error).message};
}
const firstLine = code.substring(0, code.indexOf('\n'));
const config = parseConfigPragmaFn(firstLine, {compilationMode: 'all'});
const options = {
...config,
environment: {
...config.environment,
},
logger: {
logEvent: () => {},
debugLogIRs: () => {},
},
enableReanimatedCheck: false,
};
try {
transformFromAstSync(ast, code, {
filename: '/' + filename,
highlightCode: false,
// ... (2083 more lines)
Domain
Subdomains
Functions
- astToCode()
- cloneAst()
- collectUniqueIdentifierNames()
- compileAndGetError()
- errorsMatch()
- minimize()
- removeArrayElements()
- removeArrayPatternElements()
- removeCallArguments()
- removeFunctionParameters()
- removeJSXAttributes()
- removeJSXChildren()
- removeJSXFragmentChildren()
- removeObjectPatternProperties()
- removeObjectProperties()
- removeStatements()
- renameAllIdentifiers()
- simplifyAssignmentExpressions()
- simplifyAwaitExpressions()
- simplifyBinaryExpressions()
- simplifyCallExpressions()
- simplifyConditionals()
- simplifyDoWhileStatements()
- simplifyForInStatements()
- simplifyForOfStatements()
- simplifyForStatements()
- simplifyIdentifiersRemoveOnPrefix()
- simplifyIdentifiersRemoveRefSuffix()
- simplifyIdentifiersRenameRef()
- simplifyIfStatements()
- simplifyLogicalExpressions()
- simplifyMemberExpressions()
- simplifyOptionalChains()
- simplifySingleElementArrays()
- simplifySinglePropertyObjects()
- simplifySingleStatementBlocks()
- simplifySwitchStatements()
- simplifyTryStatements()
- simplifyVariableDeclarations()
- simplifyWhileStatements()
Dependencies
- ./compiler.js
- ./constants.js
- TestUtils
- core
- generator
- traverse
- types
Imported By
Source
Frequently Asked Questions
What does minimize.ts do?
minimize.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 minimize.ts?
minimize.ts defines 40 function(s): astToCode, cloneAst, collectUniqueIdentifierNames, compileAndGetError, errorsMatch, minimize, removeArrayElements, removeArrayPatternElements, removeCallArguments, removeFunctionParameters, and 30 more.
What does minimize.ts depend on?
minimize.ts imports 7 module(s): ./compiler.js, ./constants.js, TestUtils, core, generator, traverse, types.
What files import minimize.ts?
minimize.ts is imported by 1 file(s): runner.ts.
Where is minimize.ts in the architecture?
minimize.ts is located at compiler/packages/snap/src/minimize.ts (domain: BabelCompiler, subdomain: Entrypoint, directory: compiler/packages/snap/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free