Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share Object.assign polyfill between UMD builds #10671

Merged
merged 1 commit into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions scripts/rollup/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,19 @@ function createModuleMap(paths, extractErrors, bundleType) {
return moduleMap;
}

function getNodeModules(bundleType) {
function getNodeModules(bundleType, isRenderer) {
// rather than adding the rollup node resolve plugin,
// we can instead deal with the only node module that is used
// for UMD bundles - object-assign
switch (bundleType) {
case UMD_DEV:
case UMD_PROD:
return {
'object-assign': resolve('./node_modules/object-assign/index.js'),
// Bundle object-assign once in the isomorphic React, and then use
// that from the renderer UMD. Avoids bundling it in both UMDs.
'object-assign': isRenderer
? resolve('./scripts/rollup/shims/rollup/assign.js')
: resolve('./node_modules/object-assign/index.js'),
// include the ART package modules directly by aliasing them from node_modules
'art/modes/current': resolve('./node_modules/art/modes/current.js'),
'art/modes/fast-noSideEffects': resolve(
Expand Down Expand Up @@ -286,7 +290,7 @@ function getAliases(paths, bundleType, isRenderer, extractErrors) {
bundleType
),
getInternalModules(),
getNodeModules(bundleType),
getNodeModules(bundleType, isRenderer),
getFbjsModuleAliases(bundleType)
);
}
Expand Down
48 changes: 24 additions & 24 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
{
"bundleSizes": {
"react.development.js (UMD_DEV)": {
"size": 66238,
"gzip": 16739
"size": 66336,
"gzip": 16788
},
"react.production.min.js (UMD_PROD)": {
"size": 6707,
"gzip": 2801
"size": 6716,
"gzip": 2804
},
"react.development.js (NODE_DEV)": {
"size": 56692,
"gzip": 14483
"size": 56799,
"gzip": 14530
},
"react.production.min.js (NODE_PROD)": {
"size": 5730,
"gzip": 2416
"size": 5739,
"gzip": 2421
},
"React-dev.js (FB_DEV)": {
"size": 53533,
"gzip": 13666
"size": 53683,
"gzip": 13731
},
"React-prod.js (FB_PROD)": {
"size": 25034,
"gzip": 6707
"size": 25188,
"gzip": 6767
},
"react-dom.development.js (UMD_DEV)": {
"size": 649654,
"gzip": 149173
"size": 647720,
"gzip": 148505
},
"react-dom.production.min.js (UMD_PROD)": {
"size": 103686,
"gzip": 32364
"size": 102839,
"gzip": 32049
},
"react-dom.development.js (NODE_DEV)": {
"size": 608523,
Expand Down Expand Up @@ -81,12 +81,12 @@
"gzip": 15742
},
"react-dom-server.browser.development.js (UMD_DEV)": {
"size": 136901,
"gzip": 34895
"size": 134937,
"gzip": 34221
},
"react-dom-server.browser.production.min.js (UMD_PROD)": {
"size": 15917,
"gzip": 6199
"size": 15077,
"gzip": 5914
},
"react-dom-server.browser.development.js (NODE_DEV)": {
"size": 105249,
Expand All @@ -113,12 +113,12 @@
"gzip": 6238
},
"react-art.development.js (UMD_DEV)": {
"size": 372313,
"gzip": 82691
"size": 370239,
"gzip": 81901
},
"react-art.production.min.js (UMD_PROD)": {
"size": 83447,
"gzip": 25837
"size": 82583,
"gzip": 25472
},
"react-art.development.js (NODE_DEV)": {
"size": 293850,
Expand Down
4 changes: 4 additions & 0 deletions scripts/rollup/shims/rollup/assign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var ReactInternals = require('react')
.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

module.exports = ReactInternals.assign;
2 changes: 2 additions & 0 deletions src/isomorphic/ReactEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ var React = {

__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
ReactCurrentOwner: require('ReactCurrentOwner'),
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
assign: require('object-assign'),
},
};

Expand Down