@@ -315,6 +315,45 @@ function isProfilingBundleType(bundleType) {
315
315
}
316
316
}
317
317
318
+ function getBundleTypeFlags ( bundleType ) {
319
+ const isUMDBundle =
320
+ bundleType === UMD_DEV ||
321
+ bundleType === UMD_PROD ||
322
+ bundleType === UMD_PROFILING ;
323
+ const isFBWWWBundle =
324
+ bundleType === FB_WWW_DEV ||
325
+ bundleType === FB_WWW_PROD ||
326
+ bundleType === FB_WWW_PROFILING ;
327
+ const isRNBundle =
328
+ bundleType === RN_OSS_DEV ||
329
+ bundleType === RN_OSS_PROD ||
330
+ bundleType === RN_OSS_PROFILING ||
331
+ bundleType === RN_FB_DEV ||
332
+ bundleType === RN_FB_PROD ||
333
+ bundleType === RN_FB_PROFILING ;
334
+
335
+ const isFBRNBundle =
336
+ bundleType === RN_FB_DEV ||
337
+ bundleType === RN_FB_PROD ||
338
+ bundleType === RN_FB_PROFILING ;
339
+
340
+ const shouldStayReadable = isFBWWWBundle || isRNBundle || forcePrettyOutput ;
341
+
342
+ const shouldBundleDependencies =
343
+ bundleType === UMD_DEV ||
344
+ bundleType === UMD_PROD ||
345
+ bundleType === UMD_PROFILING ;
346
+
347
+ return {
348
+ isUMDBundle,
349
+ isFBWWWBundle,
350
+ isRNBundle,
351
+ isFBRNBundle,
352
+ shouldBundleDependencies,
353
+ shouldStayReadable,
354
+ } ;
355
+ }
356
+
318
357
function forbidFBJSImports ( ) {
319
358
return {
320
359
name : 'forbidFBJSImports' ,
@@ -344,22 +383,9 @@ function getPlugins(
344
383
const forks = Modules . getForks ( bundleType , entry , moduleType , bundle ) ;
345
384
const isProduction = isProductionBundleType ( bundleType ) ;
346
385
const isProfiling = isProfilingBundleType ( bundleType ) ;
347
- const isUMDBundle =
348
- bundleType === UMD_DEV ||
349
- bundleType === UMD_PROD ||
350
- bundleType === UMD_PROFILING ;
351
- const isFBWWWBundle =
352
- bundleType === FB_WWW_DEV ||
353
- bundleType === FB_WWW_PROD ||
354
- bundleType === FB_WWW_PROFILING ;
355
- const isRNBundle =
356
- bundleType === RN_OSS_DEV ||
357
- bundleType === RN_OSS_PROD ||
358
- bundleType === RN_OSS_PROFILING ||
359
- bundleType === RN_FB_DEV ||
360
- bundleType === RN_FB_PROD ||
361
- bundleType === RN_FB_PROFILING ;
362
- const shouldStayReadable = isFBWWWBundle || isRNBundle || forcePrettyOutput ;
386
+
387
+ const { isUMDBundle, shouldStayReadable} = getBundleTypeFlags ( bundleType ) ;
388
+
363
389
return [
364
390
// Keep dynamic imports as externals
365
391
dynamicImports ( ) ,
@@ -568,25 +594,14 @@ async function createBundle(bundle, bundleType) {
568
594
const format = getFormat ( bundleType ) ;
569
595
const packageName = Packaging . getPackageName ( bundle . entry ) ;
570
596
571
- const isFBWWWBundle =
572
- bundleType === FB_WWW_DEV ||
573
- bundleType === FB_WWW_PROD ||
574
- bundleType === FB_WWW_PROFILING ;
575
-
576
- const isFBRNBundle =
577
- bundleType === RN_FB_DEV ||
578
- bundleType === RN_FB_PROD ||
579
- bundleType === RN_FB_PROFILING ;
597
+ const { isFBWWWBundle, isFBRNBundle, shouldBundleDependencies} =
598
+ getBundleTypeFlags ( bundleType ) ;
580
599
581
600
let resolvedEntry = resolveEntryFork (
582
601
require . resolve ( bundle . entry ) ,
583
602
isFBWWWBundle || isFBRNBundle
584
603
) ;
585
604
586
- const shouldBundleDependencies =
587
- bundleType === UMD_DEV ||
588
- bundleType === UMD_PROD ||
589
- bundleType === UMD_PROFILING ;
590
605
const peerGlobals = Modules . getPeerGlobals ( bundle . externals , bundleType ) ;
591
606
let externals = Object . keys ( peerGlobals ) ;
592
607
if ( ! shouldBundleDependencies ) {
0 commit comments