From 3960bc64d985c79ff497092dce5d86718ad6c027 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Mon, 20 Jul 2020 13:20:39 -0400 Subject: [PATCH] isFBBundle should be true if it's FB for www or FB for RN This ensures that the .fb.js override files kick in for RN. Otherwise we won't have FB specific exports in the isomorphic modules. --- scripts/rollup/build.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index fb0d182dc9046..6a8b7f9c2334a 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -346,7 +346,7 @@ function getPlugins( bundleType === UMD_DEV || bundleType === UMD_PROD || bundleType === UMD_PROFILING; - const isFBBundle = + const isFBWWWBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD || bundleType === FB_WWW_PROFILING; @@ -357,7 +357,7 @@ function getPlugins( bundleType === RN_FB_DEV || bundleType === RN_FB_PROD || bundleType === RN_FB_PROFILING; - const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput; + const shouldStayReadable = isFBWWWBundle || isRNBundle || forcePrettyOutput; return [ // Extract error codes from invariant() messages into a file. shouldExtractErrors && { @@ -371,7 +371,7 @@ function getPlugins( // Ensure we don't try to bundle any fbjs modules. forbidFBJSImports(), // Replace any externals with their valid internal FB mappings - isFBBundle && replace(Bundles.fbBundleExternalsMap), + isFBWWWBundle && replace(Bundles.fbBundleExternalsMap), // Use Node resolution mechanism. resolve({ skip: externals, @@ -539,14 +539,19 @@ async function createBundle(bundle, bundleType) { const format = getFormat(bundleType); const packageName = Packaging.getPackageName(bundle.entry); - const isFBBundle = + const isFBWWWBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD || bundleType === FB_WWW_PROFILING; + const isFBRNBundle = + bundleType === RN_FB_DEV || + bundleType === RN_FB_PROD || + bundleType === RN_FB_PROFILING; + let resolvedEntry = resolveEntryFork( require.resolve(bundle.entry), - isFBBundle + isFBWWWBundle || isFBRNBundle ); const shouldBundleDependencies = @@ -559,7 +564,7 @@ async function createBundle(bundle, bundleType) { const deps = Modules.getDependencies(bundleType, bundle.entry); externals = externals.concat(deps); } - if (isFBBundle) { + if (isFBWWWBundle) { // Add any mapped fb bundle externals externals = externals.concat(Object.values(Bundles.fbBundleExternalsMap)); }