diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index e5685f0115..c31c819917 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -369,6 +369,24 @@ const bundles = [ }, ]; +// Based on deep-freeze by substack (public domain) +function deepFreeze(o) { + Object.freeze(o); + Object.getOwnPropertyNames(o).forEach(function(prop) { + if ( + o[prop] !== null && + (typeof o[prop] === 'object' || typeof o[prop] === 'function') && + !Object.isFrozen(o[prop]) + ) { + deepFreeze(o[prop]); + } + }); + return o; +} + +// Don't accidentally mutate config as part of the build +deepFreeze(bundles); + module.exports = { bundleTypes, bundles, diff --git a/scripts/rollup/modules.js b/scripts/rollup/modules.js index 3f7b4070cc..24c7d7a02c 100644 --- a/scripts/rollup/modules.js +++ b/scripts/rollup/modules.js @@ -143,7 +143,7 @@ function getExternalModules(externals, bundleType, isRenderer) { // this means having a require("name-of-external-module") at // the top of the bundle. for UMD bundles this means having // both a require and a global check for them - let externalModules = externals; + let externalModules = externals.slice(); switch (bundleType) { case UMD_DEV: @@ -158,7 +158,6 @@ function getExternalModules(externals, bundleType, isRenderer) { case RN_PROD: fbjsModules.forEach(module => externalModules.push(module)); externalModules.push('object-assign'); - if (isRenderer) { externalModules.push('react'); } @@ -166,6 +165,7 @@ function getExternalModules(externals, bundleType, isRenderer) { case FB_DEV: case FB_PROD: fbjsModules.forEach(module => externalModules.push(module)); + externalModules.push('object-assign'); externalModules.push('ReactCurrentOwner'); externalModules.push('lowPriorityWarning'); if (isRenderer) {