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