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