Fix FB isomorphic build (#10704)

* Freeze bundle configs before the build

This ensures we don't accidentally mutate it.

* Fix config mutation during the build uncovered by freeze

* Fix FB isomorphic build by marking object-assign as an external

* Bye bye redundant check
This commit is contained in:
Dan Abramov
2017-09-14 01:24:31 +01:00
committed by GitHub
parent aebd7f5454
commit af36a05d5a
2 changed files with 20 additions and 2 deletions
+18
View File
@@ -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,
+2 -2
View File
@@ -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) {