Home / File/ runner-watch.ts — react Source File

runner-watch.ts — react Source File

Architecture documentation for runner-watch.ts, a typescript file in the react codebase. 8 imports, 1 dependents.

File typescript BabelCompiler Optimization 8 imports 1 dependents 8 functions

Entity Profile

Dependency Diagram

graph LR
  3c2dde8c_5e90_a277_13bd_39083b18cadb["runner-watch.ts"]
  dc3fd0be_e038_0596_3080_c93d9784f34e["constants.ts"]
  3c2dde8c_5e90_a277_13bd_39083b18cadb --> dc3fd0be_e038_0596_3080_c93d9784f34e
  4d76833e_f078_3b83_e453_82ab13e17c43["fixture-utils.ts"]
  3c2dde8c_5e90_a277_13bd_39083b18cadb --> 4d76833e_f078_3b83_e453_82ab13e17c43
  f3c89b3a_e1fb_1f97_edcb_af6fb0ae7691["TestFilter"]
  3c2dde8c_5e90_a277_13bd_39083b18cadb --> f3c89b3a_e1fb_1f97_edcb_af6fb0ae7691
  35f5a65c_e6e8_8fa8_f9c0_158316bd8913["getFixtures"]
  3c2dde8c_5e90_a277_13bd_39083b18cadb --> 35f5a65c_e6e8_8fa8_f9c0_158316bd8913
  15d397fb_dcc4_7631_d6b0_d2e1ec6e7530["watcher"]
  3c2dde8c_5e90_a277_13bd_39083b18cadb --> 15d397fb_dcc4_7631_d6b0_d2e1ec6e7530
  b402a0fc_00db_e86d_b1ea_ad4f8e9faaca["path"]
  3c2dde8c_5e90_a277_13bd_39083b18cadb --> b402a0fc_00db_e86d_b1ea_ad4f8e9faaca
  1ac6e1ce_748a_dad4_6d28_510c5260df3e["typescript"]
  3c2dde8c_5e90_a277_13bd_39083b18cadb --> 1ac6e1ce_748a_dad4_6d28_510c5260df3e
  6a88ed04_6732_212f_bbac_658bd7cb3b65["child_process"]
  3c2dde8c_5e90_a277_13bd_39083b18cadb --> 6a88ed04_6732_212f_bbac_658bd7cb3b65
  1fd49604_fb16_2568_4971_9eca12fd6a73["runner.ts"]
  1fd49604_fb16_2568_4971_9eca12fd6a73 --> 3c2dde8c_5e90_a277_13bd_39083b18cadb
  style 3c2dde8c_5e90_a277_13bd_39083b18cadb 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 watcher from '@parcel/watcher';
import path from 'path';
import ts from 'typescript';
import {FIXTURES_PATH, BABEL_PLUGIN_ROOT} from './constants';
import {TestFilter, getFixtures} from './fixture-utils';
import {execSync} from 'child_process';

export function watchSrc(
  onStart: () => void,
  onComplete: (isSuccess: boolean) => void,
): ts.WatchOfConfigFile<ts.SemanticDiagnosticsBuilderProgram> {
  const configPath = ts.findConfigFile(
    /*searchPath*/ BABEL_PLUGIN_ROOT,
    ts.sys.fileExists,
    'tsconfig.json',
  );
  if (!configPath) {
    throw new Error("Could not find a valid 'tsconfig.json'.");
  }
  const createProgram = ts.createSemanticDiagnosticsBuilderProgram;
  const host = ts.createWatchCompilerHost(
    configPath,
    undefined,
    ts.sys,
    createProgram,
    () => {}, // we manually report errors in afterProgramCreate
    () => {}, // we manually report watch status
  );

  const origCreateProgram = host.createProgram;
  host.createProgram = (rootNames, options, host, oldProgram) => {
    onStart();
    return origCreateProgram(rootNames, options, host, oldProgram);
  };
  host.afterProgramCreate = program => {
    /**
     * Avoid calling original postProgramCreate because it always emits tsc
     * compilation output
     */

    // syntactic diagnostics refer to javascript syntax
    const errors = program
      .getSyntacticDiagnostics()
      .filter(diag => diag.category === ts.DiagnosticCategory.Error);
    // semantic diagnostics refer to typescript semantics
    errors.push(
      ...program
        .getSemanticDiagnostics()
        .filter(diag => diag.category === ts.DiagnosticCategory.Error),
    );

    if (errors.length > 0) {
      for (const diagnostic of errors) {
// ... (392 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does runner-watch.ts do?
runner-watch.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 runner-watch.ts?
runner-watch.ts defines 8 function(s): editDistance, filterFixtures, makeWatchRunner, renderAutocomplete, subscribeFixtures, subscribeKeyEvents, subscribeTsc, watchSrc.
What does runner-watch.ts depend on?
runner-watch.ts imports 8 module(s): TestFilter, child_process, constants.ts, fixture-utils.ts, getFixtures, path, typescript, watcher.
What files import runner-watch.ts?
runner-watch.ts is imported by 1 file(s): runner.ts.
Where is runner-watch.ts in the architecture?
runner-watch.ts is located at compiler/packages/snap/src/runner-watch.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