Home / Function/ getBundleOutputPath() — react Function Reference

getBundleOutputPath() — react Function Reference

Architecture documentation for the getBundleOutputPath() function in packaging.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d9e97b13_c6c8_1bbc_87b4_ac995a6ee8e8["getBundleOutputPath()"]
  fef369e3_6dfd_944a_16c1_5addc35f485d["packaging.js"]
  d9e97b13_c6c8_1bbc_87b4_ac995a6ee8e8 -->|defined in| fef369e3_6dfd_944a_16c1_5addc35f485d
  style d9e97b13_c6c8_1bbc_87b4_ac995a6ee8e8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/rollup/packaging.js lines 48–115

function getBundleOutputPath(bundle, bundleType, filename, packageName) {
  switch (bundleType) {
    case NODE_ES2015:
      return `build/node_modules/${packageName}/cjs/${filename}`;
    case ESM_DEV:
    case ESM_PROD:
    case ESM_DTS:
      return `build/node_modules/${packageName}/esm/${filename}`;
    case BUN_DEV:
    case BUN_PROD:
      return `build/node_modules/${packageName}/cjs/${filename}`;
    case NODE_DEV:
    case NODE_PROD:
    case NODE_PROFILING:
    case CJS_DTS:
      return `build/node_modules/${packageName}/cjs/${filename}`;
    case FB_WWW_DEV:
    case FB_WWW_PROD:
    case FB_WWW_PROFILING:
      return `build/facebook-www/${filename}`;
    case RN_OSS_DEV:
    case RN_OSS_PROD:
    case RN_OSS_PROFILING:
      switch (packageName) {
        case 'react-native-renderer':
          return `build/react-native/implementations/${filename}`;
        default:
          throw new Error('Unknown RN package.');
      }
    case RN_FB_DEV:
    case RN_FB_PROD:
    case RN_FB_PROFILING:
      switch (packageName) {
        case 'scheduler':
        case 'react':
        case 'react-dom':
        case 'react-is':
        case 'react-test-renderer':
          return `build/facebook-react-native/${packageName}/cjs/${filename}`;
        case 'react-native-renderer':
          return `build/react-native/implementations/${filename.replace(
            /\.js$/,
            '.fb.js'
          )}`;
        default:
          throw new Error('Unknown RN package.');
      }
    case BROWSER_SCRIPT: {
      // Bundles that are served as browser scripts need to be able to be sent
      // straight to the browser with any additional bundling. We shouldn't use
      // a module to re-export. Depending on how they are served, they also may
      // not go through package.json module resolution, so we shouldn't rely on
      // that either. We should consider the output path as part of the public
      // contract, and explicitly specify its location within the package's
      // directory structure.
      const outputPath = bundle.outputPath;
      if (!outputPath) {
        throw new Error(
          'Bundles with type BROWSER_SCRIPT must specific an explicit ' +
            'output path.'
        );
      }
      return `build/node_modules/${packageName}/${outputPath}`;
    }
    default:
      throw new Error('Unknown bundle type.');
  }
}

Domain

Subdomains

Frequently Asked Questions

What does getBundleOutputPath() do?
getBundleOutputPath() is a function in the react codebase, defined in scripts/rollup/packaging.js.
Where is getBundleOutputPath() defined?
getBundleOutputPath() is defined in scripts/rollup/packaging.js at line 48.

Analyze Your Own Codebase

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

Try Supermodel Free