mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user