Home / File/ compiler.ts — react Source File

compiler.ts — react Source File

Architecture documentation for compiler.ts, a typescript file in the react codebase. 16 imports, 2 dependents.

File typescript BabelCompiler Optimization 16 imports 2 dependents 7 functions

Entity Profile

Dependency Diagram

graph LR
  f294d5ab_dd3b_6bca_e120_e970909a7dc8["compiler.ts"]
  3b4cf63e_f5d5_5d3b_afb4_8cb5b3a16d18["SproutTodoFilter.ts"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 3b4cf63e_f5d5_5d3b_afb4_8cb5b3a16d18
  4d76833e_f078_3b83_e453_82ab13e17c43["fixture-utils.ts"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 4d76833e_f078_3b83_e453_82ab13e17c43
  bf1ae175_0a76_7aa4_ad79_8ea2236e3b0a["isExpectError"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> bf1ae175_0a76_7aa4_ad79_8ea2236e3b0a
  7abd0006_a288_8ea5_5a9e_399bf42f51d6["shared-runtime-type-provider.ts"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 7abd0006_a288_8ea5_5a9e_399bf42f51d6
  be453c75_64b7_4b3f_3c65_f13f8f53e2b9["makeSharedRuntimeTypeProvider"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> be453c75_64b7_4b3f_3c65_f13f8f53e2b9
  102f7d62_f771_0080_dd43_d867f5a8bd55["core"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 102f7d62_f771_0080_dd43_d867f5a8bd55
  ba38a3cc_fa9d_cd5d_0746_ec93bcb397e1["parser"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> ba38a3cc_fa9d_cd5d_0746_ec93bcb397e1
  ceff537f_04b5_ea96_fed3_19a0a7315bc6["traverse"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> ceff537f_04b5_ea96_fed3_19a0a7315bc6
  52e3d8d7_abf4_7343_1f98_3f701ec04082["types"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 52e3d8d7_abf4_7343_1f98_3f701ec04082
  3d96d43f_3b5e_656b_d955_c4fbf4f8a2d6["Entrypoint"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 3d96d43f_3b5e_656b_d955_c4fbf4f8a2d6
  1b1704df_1925_76f5_64b1_edf9346dac74["HIR"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 1b1704df_1925_76f5_64b1_edf9346dac74
  4981ed31_eed2_3019_b790_fd237d28f366["TestUtils"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 4981ed31_eed2_3019_b790_fd237d28f366
  78f0dea0_5a25_0652_2a88_959a2ce71a1f["hermes-parser"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 78f0dea0_5a25_0652_2a88_959a2ce71a1f
  7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8["invariant"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8
  style f294d5ab_dd3b_6bca_e120_e970909a7dc8 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 * as BabelCore from '@babel/core';
import {transformFromAstSync} from '@babel/core';

import * as BabelParser from '@babel/parser';
import {NodePath} from '@babel/traverse';
import * as t from '@babel/types';
import type {
  Logger,
  LoggerEvent,
  PluginOptions,
  CompilerReactTarget,
  CompilerPipelineValue,
} from 'babel-plugin-react-compiler/src/Entrypoint';
import type {
  Effect,
  ValueKind,
  ValueReason,
} from 'babel-plugin-react-compiler/src/HIR';
import type {parseConfigPragmaForTests as ParseConfigPragma} from 'babel-plugin-react-compiler/src/Utils/TestUtils';
import * as HermesParser from 'hermes-parser';
import invariant from 'invariant';
import path from 'path';
import prettier from 'prettier';
import SproutTodoFilter from './SproutTodoFilter';
import {isExpectError} from './fixture-utils';
import {makeSharedRuntimeTypeProvider} from './sprout/shared-runtime-type-provider';

export function parseLanguage(source: string): 'flow' | 'typescript' {
  return source.indexOf('@flow') !== -1 ? 'flow' : 'typescript';
}

export function parseSourceType(source: string): 'script' | 'module' {
  return source.indexOf('@script') !== -1 ? 'script' : 'module';
}

/**
 * Parse react compiler plugin + environment options from test fixture. Note
 * that although this primarily uses `Environment:parseConfigPragma`, it also
 * has test fixture specific (i.e. not applicable to playground) parsing logic.
 */
function makePluginOptions(
  firstLine: string,
  parseConfigPragmaFn: typeof ParseConfigPragma,
  debugIRLogger: (value: CompilerPipelineValue) => void,
  EffectEnum: typeof Effect,
  ValueKindEnum: typeof ValueKind,
  ValueReasonEnum: typeof ValueReason,
): {
  options: PluginOptions;
  loggerTestOnly: boolean;
  logs: Array<{filename: string | null; event: LoggerEvent}>;
} {
  // TODO(@mofeiZ) rewrite snap fixtures to @validatePreserveExistingMemo:false
// ... (330 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does compiler.ts do?
compiler.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in compiler.ts?
compiler.ts defines 7 function(s): format, getEvaluatorPresets, makePluginOptions, parseInput, parseLanguage, parseSourceType, transformFixtureInput.
What does compiler.ts depend on?
compiler.ts imports 16 module(s): Entrypoint, HIR, SproutTodoFilter.ts, TestUtils, core, fixture-utils.ts, hermes-parser, invariant, and 8 more.
What files import compiler.ts?
compiler.ts is imported by 2 file(s): runner-worker.ts, runner.ts.
Where is compiler.ts in the architecture?
compiler.ts is located at compiler/packages/snap/src/compiler.ts (domain: BabelCompiler, subdomain: Optimization, 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