MCPcopy Index your code
hub / github.com/react/react / createBundle

Function createBundle

scripts/rollup/build.js:635–751  ·  view source on GitHub ↗
(bundle, bundleType)

Source from the content-addressed store, hash-verified

633}
634
635async function createBundle(bundle, bundleType) {
636 const filename = getFilename(bundle, bundleType);
637 const logKey =
638 chalk.white.bold(filename) + chalk.dim(` (${bundleType.toLowerCase()})`);
639 const format = getFormat(bundleType);
640 const packageName = Packaging.getPackageName(bundle.entry);
641
642 const {isFBWWWBundle, isFBRNBundle} = getBundleTypeFlags(bundleType);
643
644 const resolvedEntry = resolveEntryFork(
645 require.resolve(bundle.entry),
646 isFBWWWBundle || isFBRNBundle,
647 !isProductionBundleType(bundleType)
648 );
649
650 const peerGlobals = Modules.getPeerGlobals(bundle.externals, bundleType);
651 let externals = Object.keys(peerGlobals);
652
653 const deps = Modules.getDependencies(bundleType, bundle.entry);
654 externals = externals.concat(deps);
655
656 const importSideEffects = Modules.getImportSideEffects();
657 const pureExternalModules = Object.keys(importSideEffects).filter(
658 module => !importSideEffects[module]
659 );
660
661 const rollupConfig = {
662 input: resolvedEntry,
663 treeshake: {
664 moduleSideEffects: (id, external) =>
665 !(external && pureExternalModules.includes(id)),
666 propertyReadSideEffects: false,
667 },
668 external(id) {
669 const containsThisModule = pkg => id === pkg || id.startsWith(pkg + '/');
670 const isProvidedByDependency = externals.some(containsThisModule);
671 if (isProvidedByDependency) {
672 if (id.indexOf('/src/') !== -1) {
673 throw Error(
674 'You are trying to import ' +
675 id +
676 ' but ' +
677 externals.find(containsThisModule) +
678 ' is one of npm dependencies, ' +
679 'so it will not contain that source file. You probably want ' +
680 'to create a new bundle entry point for it instead.'
681 );
682 }
683 return true;
684 }
685 return !!peerGlobals[id];
686 },
687 onwarn: handleRollupWarning,
688 plugins: getPlugins(
689 bundle.entry,
690 bundle.babel,
691 filename,
692 packageName,

Callers 1

buildEverythingFunction · 0.85

Calls 11

getFilenameFunction · 0.85
getBundleTypeFlagsFunction · 0.85
isProductionBundleTypeFunction · 0.85
getPluginsFunction · 0.85
getRollupOutputOptionsFunction · 0.85
handleRollupErrorFunction · 0.85
keysMethod · 0.80
onMethod · 0.80
getFormatFunction · 0.70
resolveEntryForkFunction · 0.70
writeMethod · 0.65

Tested by

no test coverage detected