Home / File/ setupHostConfigs.js — react Source File

setupHostConfigs.js — react Source File

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

Entity Profile

Relationship Graph

Source Code

'use strict';

const fs = require('fs');
const nodePath = require('path');
const inlinedHostConfigs = require('../shared/inlinedHostConfigs');

function resolveEntryFork(resolvedEntry, isFBBundle) {
  // Pick which entry point fork to use:
  // .modern.fb.js
  // .classic.fb.js
  // .fb.js
  // .stable.js
  // .experimental.js
  // .js
  // or any of those plus .development.js

  if (isFBBundle) {
    // FB builds for react-dom need to alias both react-dom and react-dom/client to the same
    // entrypoint since there is only a single build for them.
    if (
      resolvedEntry.endsWith('react-dom/index.js') ||
      resolvedEntry.endsWith('react-dom/client.js') ||
      resolvedEntry.endsWith('react-dom/unstable_testing.js')
    ) {
      let specifier;
      let entrypoint;
      if (resolvedEntry.endsWith('index.js')) {
        specifier = 'react-dom';
        entrypoint = __EXPERIMENTAL__
          ? 'src/ReactDOMFB.modern.js'
          : 'src/ReactDOMFB.js';
      } else if (resolvedEntry.endsWith('client.js')) {
        specifier = 'react-dom/client';
        entrypoint = __EXPERIMENTAL__
          ? 'src/ReactDOMFB.modern.js'
          : 'src/ReactDOMFB.js';
      } else {
        // must be unstable_testing
        specifier = 'react-dom/unstable_testing';
        entrypoint = __EXPERIMENTAL__
          ? 'src/ReactDOMTestingFB.modern.js'
          : 'src/ReactDOMTestingFB.js';
      }

      resolvedEntry = nodePath.join(resolvedEntry, '..', entrypoint);
      const devEntry = resolvedEntry.replace('.js', '.development.js');
      if (__DEV__ && fs.existsSync(devEntry)) {
        return devEntry;
      }
      if (fs.existsSync(resolvedEntry)) {
        return resolvedEntry;
      }
      const fbReleaseChannel = __EXPERIMENTAL__ ? 'www-modern' : 'www-classic';
      throw new Error(
        `${fbReleaseChannel} tests are expected to alias ${specifier} to ${entrypoint} but this file was not found`
      );
    }
    const resolvedFBEntry = resolvedEntry.replace(
      '.js',
      __EXPERIMENTAL__ ? '.modern.fb.js' : '.classic.fb.js'
// ... (191 more lines)

Domain

Subdomains

Frequently Asked Questions

What does setupHostConfigs.js do?
setupHostConfigs.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in setupHostConfigs.js?
setupHostConfigs.js defines 3 function(s): mockAllConfigs, mockReact, resolveEntryFork.
Where is setupHostConfigs.js in the architecture?
setupHostConfigs.js is located at scripts/jest/setupHostConfigs.js (domain: BabelCompiler, subdomain: Entrypoint, directory: scripts/jest).

Analyze Your Own Codebase

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

Try Supermodel Free