Home / File/ forks.js — react Source File

forks.js — react Source File

Architecture documentation for forks.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

'use strict';

const fs = require('node:fs');
const {bundleTypes, moduleTypes} = require('./bundles');
const inlinedHostConfigs = require('../shared/inlinedHostConfigs');

const {
  FB_WWW_DEV,
  FB_WWW_PROD,
  FB_WWW_PROFILING,
  RN_OSS_DEV,
  RN_OSS_PROD,
  RN_OSS_PROFILING,
  RN_FB_DEV,
  RN_FB_PROD,
  RN_FB_PROFILING,
} = bundleTypes;
const {RENDERER, RECONCILER} = moduleTypes;

const RELEASE_CHANNEL = process.env.RELEASE_CHANNEL;

// Default to building in experimental mode. If the release channel is set via
// an environment variable, then check if it's "experimental".
const __EXPERIMENTAL__ =
  typeof RELEASE_CHANNEL === 'string'
    ? RELEASE_CHANNEL === 'experimental'
    : true;

function findNearestExistingForkFile(path, segmentedIdentifier, suffix) {
  const segments = segmentedIdentifier.split('-');
  while (segments.length) {
    const candidate = segments.join('-');
    const forkPath = path + candidate + suffix;
    try {
      fs.statSync(forkPath);
      return forkPath;
    } catch (error) {
      // Try the next candidate.
    }
    segments.pop();
  }
  return null;
}

// If you need to replace a file with another file for a specific environment,
// add it to this list with the logic for choosing the right replacement.

// Fork paths are relative to the project root. They must include the full path,
// including the extension. We intentionally don't use Node's module resolution
// algorithm because 1) require.resolve doesn't work with ESM modules, and 2)
// the behavior is easier to predict.
const forks = Object.freeze({
  // Without this fork, importing `shared/ReactSharedInternals` inside
  // the `react` package itself would not work due to a cyclical dependency.
  './packages/shared/ReactSharedInternals.js': (
    bundleType,
    entry,
    dependencies,
    _moduleType,
    bundle
// ... (425 more lines)

Domain

Subdomains

Frequently Asked Questions

What does forks.js do?
forks.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in forks.js?
forks.js defines 14 function(s): findNearestExistingForkFile, forks../packages/react-client/src/ReactFlightClientConfig.js, forks../packages/react-dom-bindings/src/events/EventListener.js, forks../packages/react-reconciler/src/ReactFiberConfig.js, forks../packages/react-server/src/ReactFizzConfig.js, forks../packages/react-server/src/ReactFlightServerConfig.js, forks../packages/react-server/src/ReactServerStreamConfig.js, forks../packages/scheduler/src/SchedulerFeatureFlags.js, forks../packages/shared/DefaultPrepareStackTrace.js, forks../packages/shared/ReactDOMSharedInternals.js, and 4 more.
Where is forks.js in the architecture?
forks.js is located at scripts/rollup/forks.js (domain: BabelCompiler, subdomain: Optimization, directory: scripts/rollup).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free