Home / Function/ createBundle() — react Function Reference

createBundle() — react Function Reference

Architecture documentation for the createBundle() function in build.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  bb9629f0_8ad3_5155_4bf4_2cb0aa60d724["createBundle()"]
  c80a1a72_0983_3915_42ad_1026a11c0a09["build.js"]
  bb9629f0_8ad3_5155_4bf4_2cb0aa60d724 -->|defined in| c80a1a72_0983_3915_42ad_1026a11c0a09
  4d4ca0d3_eb09_0168_db5f_50c3bfd22818["buildEverything()"]
  4d4ca0d3_eb09_0168_db5f_50c3bfd22818 -->|calls| bb9629f0_8ad3_5155_4bf4_2cb0aa60d724
  97166a69_a8ff_deec_da2e_1b3592a2cb88["getFormat()"]
  bb9629f0_8ad3_5155_4bf4_2cb0aa60d724 -->|calls| 97166a69_a8ff_deec_da2e_1b3592a2cb88
  c3469df7_bf7f_67ea_526d_74e1ae8376cd["getBundleTypeFlags()"]
  bb9629f0_8ad3_5155_4bf4_2cb0aa60d724 -->|calls| c3469df7_bf7f_67ea_526d_74e1ae8376cd
  ccd7a40e_e94d_8b85_bfcc_dd55c611c9a9["resolveEntryFork()"]
  bb9629f0_8ad3_5155_4bf4_2cb0aa60d724 -->|calls| ccd7a40e_e94d_8b85_bfcc_dd55c611c9a9
  aa87d6da_515b_1cc2_3ffd_e8382fbe791f["isProductionBundleType()"]
  bb9629f0_8ad3_5155_4bf4_2cb0aa60d724 -->|calls| aa87d6da_515b_1cc2_3ffd_e8382fbe791f
  67c68ebd_67d3_ae9b_4fd2_ce22eb678392["getPlugins()"]
  bb9629f0_8ad3_5155_4bf4_2cb0aa60d724 -->|calls| 67c68ebd_67d3_ae9b_4fd2_ce22eb678392
  76a2cff4_0ecd_37a0_37fe_95057b768be1["getRollupOutputOptions()"]
  bb9629f0_8ad3_5155_4bf4_2cb0aa60d724 -->|calls| 76a2cff4_0ecd_37a0_37fe_95057b768be1
  3ce0e110_9f1d_b1e2_86bd_0c1e010d4d72["handleRollupError()"]
  bb9629f0_8ad3_5155_4bf4_2cb0aa60d724 -->|calls| 3ce0e110_9f1d_b1e2_86bd_0c1e010d4d72
  style bb9629f0_8ad3_5155_4bf4_2cb0aa60d724 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/rollup/build.js lines 635–751

async function createBundle(bundle, bundleType) {
  const filename = getFilename(bundle, bundleType);
  const logKey =
    chalk.white.bold(filename) + chalk.dim(` (${bundleType.toLowerCase()})`);
  const format = getFormat(bundleType);
  const packageName = Packaging.getPackageName(bundle.entry);

  const {isFBWWWBundle, isFBRNBundle} = getBundleTypeFlags(bundleType);

  const resolvedEntry = resolveEntryFork(
    require.resolve(bundle.entry),
    isFBWWWBundle || isFBRNBundle,
    !isProductionBundleType(bundleType)
  );

  const peerGlobals = Modules.getPeerGlobals(bundle.externals, bundleType);
  let externals = Object.keys(peerGlobals);

  const deps = Modules.getDependencies(bundleType, bundle.entry);
  externals = externals.concat(deps);

  const importSideEffects = Modules.getImportSideEffects();
  const pureExternalModules = Object.keys(importSideEffects).filter(
    module => !importSideEffects[module]
  );

  const rollupConfig = {
    input: resolvedEntry,
    treeshake: {
      moduleSideEffects: (id, external) =>
        !(external && pureExternalModules.includes(id)),
      propertyReadSideEffects: false,
    },
    external(id) {
      const containsThisModule = pkg => id === pkg || id.startsWith(pkg + '/');
      const isProvidedByDependency = externals.some(containsThisModule);
      if (isProvidedByDependency) {
        if (id.indexOf('/src/') !== -1) {
          throw Error(
            'You are trying to import ' +
              id +
              ' but ' +
              externals.find(containsThisModule) +
              ' is one of npm dependencies, ' +
              'so it will not contain that source file. You probably want ' +
              'to create a new bundle entry point for it instead.'
          );
        }
        return true;
      }
      return !!peerGlobals[id];
    },
    onwarn: handleRollupWarning,
    plugins: getPlugins(
      bundle.entry,
      bundle.babel,
      filename,
      packageName,
      bundleType,
      bundle.global,
      bundle.moduleType,
      pureExternalModules,
      bundle
    ),
    output: {
      externalLiveBindings: false,
      freeze: false,
      interop: getRollupInteropValue,
      esModule: false,
    },
  };
  const mainOutputPath = Packaging.getBundleOutputPath(
    bundle,
    bundleType,
    filename,
    packageName
  );

  const rollupOutputOptions = getRollupOutputOptions(
    mainOutputPath,
    format,

Domain

Subdomains

Called By

Frequently Asked Questions

What does createBundle() do?
createBundle() is a function in the react codebase, defined in scripts/rollup/build.js.
Where is createBundle() defined?
createBundle() is defined in scripts/rollup/build.js at line 635.
What does createBundle() call?
createBundle() calls 7 function(s): getBundleTypeFlags, getFormat, getPlugins, getRollupOutputOptions, handleRollupError, isProductionBundleType, resolveEntryFork.
What calls createBundle()?
createBundle() is called by 1 function(s): buildEverything.

Analyze Your Own Codebase

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

Try Supermodel Free