Home / File/ ReactFlightServerConfigUnbundledBundler.js — react Source File

ReactFlightServerConfigUnbundledBundler.js — react Source File

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

File javascript BabelCompiler Validation 3 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  800b57fe_64a5_c6f9_986f_d9edff1b0aef["ReactFlightServerConfigUnbundledBundler.js"]
  2396266a_5487_f53e_5c02_e8f8112f09c9["ReactFlightImportMetadata.js"]
  800b57fe_64a5_c6f9_986f_d9edff1b0aef --> 2396266a_5487_f53e_5c02_e8f8112f09c9
  3668d0cf_c7c5_71f0_043b_52567ce7585c["ReactFlightUnbundledReferences.js"]
  800b57fe_64a5_c6f9_986f_d9edff1b0aef --> 3668d0cf_c7c5_71f0_043b_52567ce7585c
  0cf33a2a_6fe6_7412_bf8d_09664538a80f["ReactFlightServer"]
  800b57fe_64a5_c6f9_986f_d9edff1b0aef --> 0cf33a2a_6fe6_7412_bf8d_09664538a80f
  a5236203_d909_42f3_0aa4_326ef7a7b930["ReactFlightDOMServerNode.js"]
  a5236203_d909_42f3_0aa4_326ef7a7b930 --> 800b57fe_64a5_c6f9_986f_d9edff1b0aef
  style 800b57fe_64a5_c6f9_986f_d9edff1b0aef 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 '../ReactFlightUnbundledReferences';

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 '../ReactFlightUnbundledReferences';

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 ReactFlightServerConfigUnbundledBundler.js do?
ReactFlightServerConfigUnbundledBundler.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 ReactFlightServerConfigUnbundledBundler.js?
ReactFlightServerConfigUnbundledBundler.js defines 1 function(s): getClientReferenceKey.
What does ReactFlightServerConfigUnbundledBundler.js depend on?
ReactFlightServerConfigUnbundledBundler.js imports 3 module(s): ReactFlightImportMetadata.js, ReactFlightServer, ReactFlightUnbundledReferences.js.
What files import ReactFlightServerConfigUnbundledBundler.js?
ReactFlightServerConfigUnbundledBundler.js is imported by 1 file(s): ReactFlightDOMServerNode.js.
Where is ReactFlightServerConfigUnbundledBundler.js in the architecture?
ReactFlightServerConfigUnbundledBundler.js is located at packages/react-server-dom-unbundled/src/server/ReactFlightServerConfigUnbundledBundler.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-server-dom-unbundled/src/server).

Analyze Your Own Codebase

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

Try Supermodel Free