Skip to content

Commit

Permalink
Allow transitive deps on fbjs/ for UMD bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jun 19, 2018
1 parent f69d7c9 commit b4ac234
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scripts/rollup/build.js
Expand Up @@ -240,11 +240,11 @@ function isProfilingBundleType(bundleType) {
function blacklistFBJS() {
return {
name: 'blacklistFBJS',
resolveId(importee) {
resolveId(importee, importer) {
if (/^fbjs\//.test(importee)) {
throw new Error(
`Don't import ${importee}. ` +
`Check out the utilities in packages/shared/ instead.`
`Don't import ${importee} (found in ${importer}). ` +
`Use the utilities in packages/shared/ instead.`
);
}
},
Expand All @@ -266,7 +266,7 @@ function getPlugins(
const forks = Modules.getForks(bundleType, entry, moduleType);
const isProduction = isProductionBundleType(bundleType);
const isProfiling = isProfilingBundleType(bundleType);
const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD;
const isUMDBundle = bundleType === UMD_DEV || bundleType === UMD_PROD;
const isFBBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD;
const isRNBundle =
bundleType === RN_OSS_DEV ||
Expand All @@ -285,8 +285,9 @@ function getPlugins(
},
// Shim any modules that need forking in this environment.
useForks(forks),
// Ensure we don't bundle any fbjs modules
blacklistFBJS(),
// Ensure we don't try to bundle any fbjs modules
// unless they're transitive (e.g. through prop-types).
!isUMDBundle && blacklistFBJS(),
// Use Node resolution mechanism.
resolve({
skip: externals,
Expand Down Expand Up @@ -325,7 +326,7 @@ function getPlugins(
Object.assign({}, closureOptions, {
// Don't let it create global variables in the browser.
// https://github.com/facebook/react/issues/10909
assume_function_wrapper: !isInGlobalScope,
assume_function_wrapper: !isUMDBundle,
// Works because `google-closure-compiler-js` is forked in Yarn lockfile.
// We can remove this if GCC merges my PR:
// https://github.com/google/closure-compiler/pull/2707
Expand Down

0 comments on commit b4ac234

Please sign in to comment.