Home / File/ main.ts — react Source File

main.ts — react Source File

Architecture documentation for main.ts, a typescript file in the react codebase. 5 imports, 0 dependents.

File typescript 5 imports

Entity Profile

Dependency Diagram

graph LR
  8fcecd02_b46e_e3cd_7da4_5b77f6b32738["main.ts"]
  6a88ed04_6732_212f_bbac_658bd7cb3b65["child_process"]
  8fcecd02_b46e_e3cd_7da4_5b77f6b32738 --> 6a88ed04_6732_212f_bbac_658bd7cb3b65
  7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8["invariant"]
  8fcecd02_b46e_e3cd_7da4_5b77f6b32738 --> 7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8
  47f79385_6f83_9671_b0d9_5f2bbc54305b["process"]
  8fcecd02_b46e_e3cd_7da4_5b77f6b32738 --> 47f79385_6f83_9671_b0d9_5f2bbc54305b
  0868a023_5f63_da75_bb48_967ae392d4fe["readline"]
  8fcecd02_b46e_e3cd_7da4_5b77f6b32738 --> 0868a023_5f63_da75_bb48_967ae392d4fe
  f2f70f7f_4257_ce15_7920_89c5f706139a["helpers"]
  8fcecd02_b46e_e3cd_7da4_5b77f6b32738 --> f2f70f7f_4257_ce15_7920_89c5f706139a
  style 8fcecd02_b46e_e3cd_7da4_5b77f6b32738 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 {fork} from 'child_process';
import invariant from 'invariant';
import process from 'process';
import * as readline from 'readline';
import {hideBin} from 'yargs/helpers';

readline.emitKeypressEvents(process.stdin);

if (process.stdin.isTTY) {
  process.stdin.setRawMode(true);
}

process.stdin.on('keypress', function (_, key) {
  if (key && key.name === 'c' && key.ctrl) {
    // handle sigint
    if (childProc) {
      console.log('Interrupted!!');
      childProc.kill('SIGINT');
      childProc.unref();
      process.exit(-1);
    }
  }
});

const childProc = fork(require.resolve('./runner.js'), hideBin(process.argv), {
  // for some reason, keypress events aren't sent to handlers in both processes
  // when we `inherit` stdin.
  // pipe stdout and stderr so we can silence child process after parent exits
  stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
  // forward existing env variables, like `NODE_OPTIONS` which VSCode uses to attach
  // its debugger
  env: {...process.env, FORCE_COLOR: 'true'},
});

invariant(
  childProc.stdin && childProc.stdout && childProc.stderr,
  'Expected forked process to have piped stdio',
);
process.stdin.pipe(childProc.stdin);
childProc.stdout.pipe(process.stdout);
childProc.stderr.pipe(process.stderr);

childProc.on('exit', code => {
  process.exit(code ?? -1);
});

Dependencies

  • child_process
  • helpers
  • invariant
  • process
  • readline

Frequently Asked Questions

What does main.ts do?
main.ts is a source file in the react codebase, written in typescript.
What does main.ts depend on?
main.ts imports 5 module(s): child_process, helpers, invariant, process, readline.
Where is main.ts in the architecture?
main.ts is located at compiler/packages/snap/src/main.ts (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