Home / File/ ReactFlightServerConfigTurbopackBundler.js — react Source File

ReactFlightServerConfigTurbopackBundler.js — react Source File

Architecture documentation for ReactFlightServerConfigTurbopackBundler.js, a javascript file in the react codebase. 3 imports, 3 dependents.

File javascript BabelCompiler Validation 3 imports 3 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  4bcd55b1_aada_3a88_c5ad_77472e72a202["ReactFlightServerConfigTurbopackBundler.js"]
  8c630d72_8245_cbaa_84bb_2d827c5947cf["ReactFlightImportMetadata.js"]
  4bcd55b1_aada_3a88_c5ad_77472e72a202 --> 8c630d72_8245_cbaa_84bb_2d827c5947cf
  659d37ac_3363_3ecd_c7ab_a756bd1f84fb["ReactFlightTurbopackReferences.js"]
  4bcd55b1_aada_3a88_c5ad_77472e72a202 --> 659d37ac_3363_3ecd_c7ab_a756bd1f84fb
  0cf33a2a_6fe6_7412_bf8d_09664538a80f["ReactFlightServer"]
  4bcd55b1_aada_3a88_c5ad_77472e72a202 --> 0cf33a2a_6fe6_7412_bf8d_09664538a80f
  afd6f182_b809_4537_225e_01209ba59678["ReactFlightDOMServerBrowser.js"]
  afd6f182_b809_4537_225e_01209ba59678 --> 4bcd55b1_aada_3a88_c5ad_77472e72a202
  ece7c63b_0c55_6bf1_e8b6_91c34226c13c["ReactFlightDOMServerEdge.js"]
  ece7c63b_0c55_6bf1_e8b6_91c34226c13c --> 4bcd55b1_aada_3a88_c5ad_77472e72a202
  be145b7b_03ae_de72_1eea_19ff10525b09["ReactFlightDOMServerNode.js"]
  be145b7b_03ae_de72_1eea_19ff10525b09 --> 4bcd55b1_aada_3a88_c5ad_77472e72a202
  style 4bcd55b1_aada_3a88_c5ad_77472e72a202 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.
 *
 * @flow
 */

import type {ReactClientValue} from 'react-server/src/ReactFlightServer';
import type {
  ImportMetadata,
  ImportManifestEntry,
} from '../shared/ReactFlightImportMetadata';

import type {
  ClientReference,
  ServerReference,
} from '../ReactFlightTurbopackReferences';

export type {ClientReference, ServerReference};

export type ClientManifest = {
  [id: string]: ClientReferenceManifestEntry,
};

export type ServerReferenceId = string;

export type ClientReferenceMetadata = ImportMetadata;
export opaque type ClientReferenceManifestEntry = ImportManifestEntry;

export type ClientReferenceKey = string;

export {
  isClientReference,
  isServerReference,
} from '../ReactFlightTurbopackReferences';

export function getClientReferenceKey(
  reference: ClientReference<any>,
): ClientReferenceKey {
  return reference.$$async ? reference.$$id + '#async' : reference.$$id;
}

export function resolveClientReferenceMetadata<T>(
  config: ClientManifest,
  clientReference: ClientReference<T>,
): ClientReferenceMetadata {
  const modulePath = clientReference.$$id;
  let name = '';
  let resolvedModuleData = config[modulePath];
  if (resolvedModuleData) {
    // The potentially aliased name.
    name = resolvedModuleData.name;
  } else {
    // We didn't find this specific export name but we might have the * export
    // which contains this name as well.
    // TODO: It's unfortunate that we now have to parse this string. We should
    // probably go back to encoding path and name separately on the client reference.
    const idx = modulePath.lastIndexOf('#');
    if (idx !== -1) {
      name = modulePath.slice(idx + 1);
      resolvedModuleData = config[modulePath.slice(0, idx)];
    }
    if (!resolvedModuleData) {
      throw new Error(
        'Could not find the module "' +
          modulePath +
          '" in the React Client Manifest. ' +
          'This is probably a bug in the React Server Components bundler.',
      );
    }
  }
  if (resolvedModuleData.async === true && clientReference.$$async === true) {
    throw new Error(
      'The module "' +
        modulePath +
        '" is marked as an async ESM module but was loaded as a CJS proxy. ' +
        'This is probably a bug in the React Server Components bundler.',
    );
  }
  if (resolvedModuleData.async === true || clientReference.$$async === true) {
    return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1];
  } else {
    return [resolvedModuleData.id, resolvedModuleData.chunks, name];
  }
}

export function getServerReferenceId<T>(
  config: ClientManifest,
  serverReference: ServerReference<T>,
): ServerReferenceId {
  return serverReference.$$id;
}

export function getServerReferenceBoundArguments<T>(
  config: ClientManifest,
  serverReference: ServerReference<T>,
): null | Array<ReactClientValue> {
  return serverReference.$$bound;
}

export function getServerReferenceLocation<T>(
  config: ClientManifest,
  serverReference: ServerReference<T>,
): void | Error {
  return serverReference.$$location;
}

Domain

Subdomains

Frequently Asked Questions

What does ReactFlightServerConfigTurbopackBundler.js do?
ReactFlightServerConfigTurbopackBundler.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactFlightServerConfigTurbopackBundler.js?
ReactFlightServerConfigTurbopackBundler.js defines 1 function(s): getClientReferenceKey.
What does ReactFlightServerConfigTurbopackBundler.js depend on?
ReactFlightServerConfigTurbopackBundler.js imports 3 module(s): ReactFlightImportMetadata.js, ReactFlightServer, ReactFlightTurbopackReferences.js.
What files import ReactFlightServerConfigTurbopackBundler.js?
ReactFlightServerConfigTurbopackBundler.js is imported by 3 file(s): ReactFlightDOMServerBrowser.js, ReactFlightDOMServerEdge.js, ReactFlightDOMServerNode.js.
Where is ReactFlightServerConfigTurbopackBundler.js in the architecture?
ReactFlightServerConfigTurbopackBundler.js is located at packages/react-server-dom-turbopack/src/server/ReactFlightServerConfigTurbopackBundler.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-server-dom-turbopack/src/server).

Analyze Your Own Codebase

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

Try Supermodel Free