From 5dd42d188ceb374731e27725f0db911bc3c18996 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 2 Aug 2017 22:29:01 +0100 Subject: [PATCH 1/7] Use single entry point for SSR via browser field --- packages/react-dom/node-stream.js | 7 --- packages/react-dom/package.json | 5 +- packages/react-dom/server.js | 4 +- scripts/rollup/bundles.js | 14 ++--- scripts/rollup/results.json | 56 +++++++++++++------ src/node_modules/react-dom/node-stream.js | 14 ----- src/node_modules/react-dom/server.js | 2 +- ...Entry.js => ReactDOMServerBrowserEntry.js} | 2 +- ...eamEntry.js => ReactDOMServerNodeEntry.js} | 5 +- .../ReactDOMServerIntegration-test.js | 11 +--- 10 files changed, 60 insertions(+), 60 deletions(-) delete mode 100644 packages/react-dom/node-stream.js delete mode 100644 src/node_modules/react-dom/node-stream.js rename src/renderers/dom/{ReactDOMServerEntry.js => ReactDOMServerBrowserEntry.js} (93%) rename src/renderers/dom/{ReactDOMNodeStreamEntry.js => ReactDOMServerNodeEntry.js} (73%) diff --git a/packages/react-dom/node-stream.js b/packages/react-dom/node-stream.js deleted file mode 100644 index aa97d0887c240..0000000000000 --- a/packages/react-dom/node-stream.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./cjs/react-dom-node-stream.production.min.js'); -} else { - module.exports = require('./cjs/react-dom-node-stream.development.js'); -} diff --git a/packages/react-dom/package.json b/packages/react-dom/package.json index f013648b6e097..d8fe2bdff34e6 100644 --- a/packages/react-dom/package.json +++ b/packages/react-dom/package.json @@ -27,12 +27,15 @@ "README.md", "index.js", "server.js", - "node-stream.js", "test-utils.js", "unstable-native-dependencies.js", "cjs/", "umd/" ], + "browser": { + "./cjs/react-dom-server-node.development.js": "./cjs/react-dom-server-browser.development.js", + "./cjs/react-dom-server-node.production.min.js": "./cjs/react-dom-server-browser.production.min.js" + }, "browserify": { "transform": [ "loose-envify" diff --git a/packages/react-dom/server.js b/packages/react-dom/server.js index 1354ce851480e..79fb72163dbf8 100644 --- a/packages/react-dom/server.js +++ b/packages/react-dom/server.js @@ -1,7 +1,7 @@ 'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./cjs/react-dom-server.production.min.js'); + module.exports = require('./cjs/react-dom-server-node.production.min.js'); } else { - module.exports = require('./cjs/react-dom-server.development.js'); + module.exports = require('./cjs/react-dom-server-node.development.js'); } diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index e4858f8ccb5cd..f6263f5f2a384 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -172,14 +172,14 @@ const bundles = [ moduleName: 'ReactDOMServer', sourceMap: false, }, - entry: 'src/renderers/dom/ReactDOMServerEntry', + entry: 'src/renderers/dom/ReactDOMServerBrowserEntry', externals: ['prop-types', 'prop-types/checkPropTypes'], - fbEntry: 'src/renderers/dom/ReactDOMServerEntry', + fbEntry: 'src/renderers/dom/ReactDOMServerBrowserEntry', hasteName: 'ReactDOMServer', isRenderer: true, - label: 'dom-server-string', + label: 'dom-server-browser', manglePropertiesOnProd: false, - name: 'react-dom/server', + name: 'react-dom/server-browser', paths: [ 'src/renderers/dom/**/*.js', 'src/renderers/shared/**/*.js', @@ -199,12 +199,12 @@ const bundles = [ moduleName: 'ReactDOMNodeStream', sourceMap: false, }, - entry: 'src/renderers/dom/ReactDOMNodeStreamEntry', + entry: 'src/renderers/dom/ReactDOMServerNodeEntry', externals: ['prop-types', 'prop-types/checkPropTypes', 'stream'], isRenderer: true, - label: 'dom-server-node-stream', + label: 'dom-server-server-node', manglePropertiesOnProd: false, - name: 'react-dom/node-stream', + name: 'react-dom/server-node', paths: [ 'src/renderers/dom/**/*.js', 'src/renderers/shared/**/*.js', diff --git a/scripts/rollup/results.json b/scripts/rollup/results.json index a63292212b287..a93958aa676cd 100644 --- a/scripts/rollup/results.json +++ b/scripts/rollup/results.json @@ -25,28 +25,28 @@ "gzip": 6703 }, "react-dom.development.js (UMD_DEV)": { - "size": 639824, - "gzip": 145999 + "size": 640604, + "gzip": 146616 }, "react-dom.production.min.js (UMD_PROD)": { - "size": 121920, - "gzip": 38871 + "size": 121735, + "gzip": 38859 }, "react-dom.development.js (NODE_DEV)": { - "size": 599220, - "gzip": 136402 + "size": 599999, + "gzip": 136960 }, "react-dom.production.min.js (NODE_PROD)": { - "size": 118838, - "gzip": 37788 + "size": 118657, + "gzip": 37769 }, "ReactDOMFiber-dev.js (FB_DEV)": { - "size": 595749, - "gzip": 135868 + "size": 596499, + "gzip": 136409 }, "ReactDOMFiber-prod.js (FB_PROD)": { - "size": 431003, - "gzip": 96867 + "size": 430689, + "gzip": 96928 }, "react-dom-test-utils.development.js (NODE_DEV)": { "size": 56074, @@ -181,12 +181,12 @@ "gzip": 50920 }, "ReactDOMServer-dev.js (FB_DEV)": { - "size": 91224, - "gzip": 23517 + "size": 91053, + "gzip": 23562 }, "ReactDOMServer-prod.js (FB_PROD)": { - "size": 55353, - "gzip": 15240 + "size": 49472, + "gzip": 13857 }, "react-dom-node-stream.development.js (NODE_DEV)": { "size": 93872, @@ -227,6 +227,30 @@ "ReactDOMUnstableNativeDependencies-prod.js (FB_PROD)": { "size": 67256, "gzip": 16011 + }, + "react-dom-server-browser.development.js (UMD_DEV)": { + "size": 122830, + "gzip": 31052 + }, + "react-dom-server-browser.production.min.js (UMD_PROD)": { + "size": 21723, + "gzip": 8267 + }, + "react-dom-server-browser.development.js (NODE_DEV)": { + "size": 91970, + "gzip": 23650 + }, + "react-dom-server-browser.production.min.js (NODE_PROD)": { + "size": 20124, + "gzip": 7655 + }, + "react-dom-server-node.development.js (NODE_DEV)": { + "size": 93701, + "gzip": 24143 + }, + "react-dom-server-node.production.min.js (NODE_PROD)": { + "size": 20958, + "gzip": 7968 } } } \ No newline at end of file diff --git a/src/node_modules/react-dom/node-stream.js b/src/node_modules/react-dom/node-stream.js deleted file mode 100644 index b0adbb2330483..0000000000000 --- a/src/node_modules/react-dom/node-stream.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags'); -var useFiber = ReactDOMFeatureFlags.useFiber; - -module.exports = useFiber - ? require('ReactDOMNodeStreamEntry') - : null; diff --git a/src/node_modules/react-dom/server.js b/src/node_modules/react-dom/server.js index a71511a094d97..fa6285bfefc07 100644 --- a/src/node_modules/react-dom/server.js +++ b/src/node_modules/react-dom/server.js @@ -10,5 +10,5 @@ var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags'); var useFiber = ReactDOMFeatureFlags.useFiber; module.exports = useFiber - ? require('ReactDOMServerEntry') + ? require('ReactDOMServerNodeEntry') : require('ReactDOMServerStackEntry'); diff --git a/src/renderers/dom/ReactDOMServerEntry.js b/src/renderers/dom/ReactDOMServerBrowserEntry.js similarity index 93% rename from src/renderers/dom/ReactDOMServerEntry.js rename to src/renderers/dom/ReactDOMServerBrowserEntry.js index 48880041dc483..b0f90f4245674 100644 --- a/src/renderers/dom/ReactDOMServerEntry.js +++ b/src/renderers/dom/ReactDOMServerBrowserEntry.js @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule ReactDOMServerEntry + * @providesModule ReactDOMServerBrowserEntry */ 'use strict'; diff --git a/src/renderers/dom/ReactDOMNodeStreamEntry.js b/src/renderers/dom/ReactDOMServerNodeEntry.js similarity index 73% rename from src/renderers/dom/ReactDOMNodeStreamEntry.js rename to src/renderers/dom/ReactDOMServerNodeEntry.js index 9353ef804c279..f75fdab33da41 100644 --- a/src/renderers/dom/ReactDOMNodeStreamEntry.js +++ b/src/renderers/dom/ReactDOMServerNodeEntry.js @@ -6,17 +6,20 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule ReactDOMNodeStreamEntry + * @providesModule ReactDOMServerNodeEntry */ 'use strict'; +var ReactDOMStringRenderer = require('ReactDOMStringRenderer'); var ReactDOMNodeStreamRenderer = require('ReactDOMNodeStreamRenderer'); var ReactVersion = require('ReactVersion'); require('ReactDOMInjection'); module.exports = { + renderToString: ReactDOMStringRenderer.renderToString, + renderToStaticMarkup: ReactDOMStringRenderer.renderToStaticMarkup, renderToStream: ReactDOMNodeStreamRenderer.renderToStream, renderToStaticStream: ReactDOMNodeStreamRenderer.renderToStaticStream, version: ReactVersion, diff --git a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js index b12e66b4daf4e..2f7c137cbb161 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js @@ -18,7 +18,6 @@ let PropTypes; let React; let ReactDOM; let ReactDOMServer; -let ReactDOMNodeStream; let ReactTestUtils; const stream = require('stream'); @@ -120,7 +119,7 @@ async function renderIntoStream(reactElement, errorCount = 0) { () => new Promise(resolve => { let writable = new DrainWritable(); - ReactDOMNodeStream.renderToStream(reactElement).pipe(writable); + ReactDOMServer.renderToStream(reactElement).pipe(writable); writable.on('finish', () => resolve(writable.buffer)); }), errorCount, @@ -347,14 +346,6 @@ function resetModules() { } require('ReactFeatureFlags').disableNewFiberFeatures = false; ReactDOMServer = require('react-dom/server'); - - // Finally, reset modules one more time before importing the stream renderer. - jest.resetModuleRegistry(); - if (typeof onAfterResetModules === 'function') { - onAfterResetModules(); - } - require('ReactFeatureFlags').disableNewFiberFeatures = false; - ReactDOMNodeStream = require('react-dom/node-stream'); } describe('ReactDOMServerIntegration', () => { From 3667cab3bf3427313548ac482f9621293c35d092 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 3 Aug 2017 00:04:54 +0100 Subject: [PATCH 2/7] Add server.browser entry point and smoke tests --- packages/react-dom/package.json | 4 +- packages/react-dom/server.browser.js | 7 ++ src/node_modules/react-dom/server.browser.js | 14 ++++ .../dom/ReactDOMServerBrowserEntry.js | 15 ++++ .../ReactServerRenderingBrowser-test.js | 75 +++++++++++++++++++ 5 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 packages/react-dom/server.browser.js create mode 100644 src/node_modules/react-dom/server.browser.js create mode 100644 src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js diff --git a/packages/react-dom/package.json b/packages/react-dom/package.json index d8fe2bdff34e6..b964ad54ded00 100644 --- a/packages/react-dom/package.json +++ b/packages/react-dom/package.json @@ -27,14 +27,14 @@ "README.md", "index.js", "server.js", + "server.browser.js", "test-utils.js", "unstable-native-dependencies.js", "cjs/", "umd/" ], "browser": { - "./cjs/react-dom-server-node.development.js": "./cjs/react-dom-server-browser.development.js", - "./cjs/react-dom-server-node.production.min.js": "./cjs/react-dom-server-browser.production.min.js" + "./server.js": "./server.browser.js" }, "browserify": { "transform": [ diff --git a/packages/react-dom/server.browser.js b/packages/react-dom/server.browser.js new file mode 100644 index 0000000000000..5c797e226ad9b --- /dev/null +++ b/packages/react-dom/server.browser.js @@ -0,0 +1,7 @@ +'use strict'; + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./cjs/react-dom-server-browser.production.min.js'); +} else { + module.exports = require('./cjs/react-dom-server-browser.development.js'); +} diff --git a/src/node_modules/react-dom/server.browser.js b/src/node_modules/react-dom/server.browser.js new file mode 100644 index 0000000000000..8c08b1d6768b6 --- /dev/null +++ b/src/node_modules/react-dom/server.browser.js @@ -0,0 +1,14 @@ +/** + * Copyright 2016-present Facebook. All Rights Reserved. + * + * @flow + */ + +'use strict'; + +var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags'); +var useFiber = ReactDOMFeatureFlags.useFiber; + +module.exports = useFiber + ? require('ReactDOMServerBrowserEntry') + : require('ReactDOMServerStackEntry'); diff --git a/src/renderers/dom/ReactDOMServerBrowserEntry.js b/src/renderers/dom/ReactDOMServerBrowserEntry.js index b0f90f4245674..9980839db94d1 100644 --- a/src/renderers/dom/ReactDOMServerBrowserEntry.js +++ b/src/renderers/dom/ReactDOMServerBrowserEntry.js @@ -13,11 +13,26 @@ var ReactDOMStringRenderer = require('ReactDOMStringRenderer'); var ReactVersion = require('ReactVersion'); +var invariant = require('invariant'); require('ReactDOMInjection'); module.exports = { renderToString: ReactDOMStringRenderer.renderToString, renderToStaticMarkup: ReactDOMStringRenderer.renderToStaticMarkup, + renderToStream() { + invariant( + false, + 'ReactDOMServer.renderToStream(): The streaming API is not available ' + + 'in the browser. Use ReactDOMServer.renderToString() instead.', + ); + }, + renderToStaticStream() { + invariant( + false, + 'ReactDOMServer.renderToStaticStream(): The streaming API is not available ' + + 'in the browser. Use ReactDOMServer.renderToStaticMarkup() instead.', + ); + }, version: ReactVersion, }; diff --git a/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js b/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js new file mode 100644 index 0000000000000..703e88860db8d --- /dev/null +++ b/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js @@ -0,0 +1,75 @@ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @emails react-core + */ + +'use strict'; + +var React; +var ReactDOM; +var ReactDOMServer; +var ReactDOMServerBrowser; + +var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags'); + +describe('ReactServerRenderingBrowser', () => { + beforeEach(() => { + jest.resetModules(); + React = require('react'); + ReactDOMServer = require('react-dom/server'); + ReactDOMServerBrowser = require('react-dom/server.browser'); + }); + + it('provides the same top-level API as react-dom/server', () => { + expect(Object.keys(ReactDOMServerBrowser)).toEqual(Object.keys(ReactDOMServer)); + }); + + it('returns the same results as react-dom/server', () => { + class Nice extends React.Component { + render() { + return

I am feeling very good today, thanks, how are you?

+ } + } + function Greeting() { + return ( +
+

How are you?

+ +
+ ); + } + expect( + ReactDOMServerBrowser.renderToString() + ).toEqual( + ReactDOMServer.renderToString() + ); + expect( + ReactDOMServerBrowser.renderToStaticMarkup() + ).toEqual( + ReactDOMServer.renderToStaticMarkup() + ); + }); + + if (ReactDOMFeatureFlags.useFiber) { + it('throws meaningfully for server-only APIs', () => { + expect(() => + ReactDOMServerBrowser.renderToStream(
) + ).toThrow( + 'ReactDOMServer.renderToStream(): The streaming API is not available ' + + 'in the browser. Use ReactDOMServer.renderToString() instead.' + ); + expect(() => + ReactDOMServerBrowser.renderToStaticStream(
) + ).toThrow( + 'ReactDOMServer.renderToStaticStream(): The streaming API is not available ' + + 'in the browser. Use ReactDOMServer.renderToStaticMarkup() instead.' + ); + }); + } +}); From c886c0cce0a920331dee3d74aa233e2783e87aa7 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 3 Aug 2017 00:07:15 +0100 Subject: [PATCH 3/7] Tweak bundle naming --- packages/react-dom/server.browser.js | 4 ++-- packages/react-dom/server.js | 4 ++-- scripts/rollup/bundles.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-dom/server.browser.js b/packages/react-dom/server.browser.js index 5c797e226ad9b..32b4953bb3500 100644 --- a/packages/react-dom/server.browser.js +++ b/packages/react-dom/server.browser.js @@ -1,7 +1,7 @@ 'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./cjs/react-dom-server-browser.production.min.js'); + module.exports = require('./cjs/react-dom-server.browser.production.min.js'); } else { - module.exports = require('./cjs/react-dom-server-browser.development.js'); + module.exports = require('./cjs/react-dom-server.browser.development.js'); } diff --git a/packages/react-dom/server.js b/packages/react-dom/server.js index 79fb72163dbf8..c45c37af6f37c 100644 --- a/packages/react-dom/server.js +++ b/packages/react-dom/server.js @@ -1,7 +1,7 @@ 'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./cjs/react-dom-server-node.production.min.js'); + module.exports = require('./cjs/react-dom-server.node.production.min.js'); } else { - module.exports = require('./cjs/react-dom-server-node.development.js'); + module.exports = require('./cjs/react-dom-server.node.development.js'); } diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index f6263f5f2a384..ae7cb553cb48d 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -179,7 +179,7 @@ const bundles = [ isRenderer: true, label: 'dom-server-browser', manglePropertiesOnProd: false, - name: 'react-dom/server-browser', + name: 'react-dom/server.browser', paths: [ 'src/renderers/dom/**/*.js', 'src/renderers/shared/**/*.js', @@ -204,7 +204,7 @@ const bundles = [ isRenderer: true, label: 'dom-server-server-node', manglePropertiesOnProd: false, - name: 'react-dom/server-node', + name: 'react-dom/server.node', paths: [ 'src/renderers/dom/**/*.js', 'src/renderers/shared/**/*.js', From b9de44231acc76b9e89381af38f76d87fde3047c Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 3 Aug 2017 00:09:34 +0100 Subject: [PATCH 4/7] Fix import --- src/renderers/dom/ReactDOMServerBrowserEntry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderers/dom/ReactDOMServerBrowserEntry.js b/src/renderers/dom/ReactDOMServerBrowserEntry.js index 9980839db94d1..cde86ab8b1d85 100644 --- a/src/renderers/dom/ReactDOMServerBrowserEntry.js +++ b/src/renderers/dom/ReactDOMServerBrowserEntry.js @@ -13,7 +13,7 @@ var ReactDOMStringRenderer = require('ReactDOMStringRenderer'); var ReactVersion = require('ReactVersion'); -var invariant = require('invariant'); +var invariant = require('fbjs/lib/invariant'); require('ReactDOMInjection'); From 17a28563a395ca57f70cc70c8ff8674da931ebc2 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 3 Aug 2017 00:16:39 +0100 Subject: [PATCH 5/7] Re-record --- scripts/rollup/results.json | 236 ++++++++++++------------------------ 1 file changed, 78 insertions(+), 158 deletions(-) diff --git a/scripts/rollup/results.json b/scripts/rollup/results.json index a93958aa676cd..4e02aa697b9be 100644 --- a/scripts/rollup/results.json +++ b/scripts/rollup/results.json @@ -49,68 +49,92 @@ "gzip": 96928 }, "react-dom-test-utils.development.js (NODE_DEV)": { - "size": 56074, - "gzip": 14162 + "size": 55917, + "gzip": 14141 }, "ReactTestUtils-dev.js (FB_DEV)": { - "size": 55864, - "gzip": 14128 + "size": 55707, + "gzip": 14105 }, - "ReactDOMServerStack-dev.js (FB_DEV)": { - "size": 460810, - "gzip": 111966 + "react-dom-unstable-native-dependencies.development.js (UMD_DEV)": { + "size": 89486, + "gzip": 22619 + }, + "react-dom-unstable-native-dependencies.production.min.js (UMD_PROD)": { + "size": 18338, + "gzip": 5956 + }, + "react-dom-unstable-native-dependencies.development.js (NODE_DEV)": { + "size": 82914, + "gzip": 20689 + }, + "react-dom-unstable-native-dependencies.production.min.js (NODE_PROD)": { + "size": 16978, + "gzip": 5429 + }, + "ReactDOMUnstableNativeDependencies-dev.js (FB_DEV)": { + "size": 82613, + "gzip": 20656 }, - "ReactDOMServerStack-prod.js (FB_PROD)": { - "size": 338222, - "gzip": 81957 + "ReactDOMUnstableNativeDependencies-prod.js (FB_PROD)": { + "size": 67256, + "gzip": 16011 }, - "react-dom-server.development.js (UMD_DEV)": { - "size": 122993, - "gzip": 31032 + "react-dom-server.browser.development.js (UMD_DEV)": { + "size": 123259, + "gzip": 31130 }, - "react-dom-server.production.min.js (UMD_PROD)": { - "size": 22819, - "gzip": 8627 + "react-dom-server.browser.production.min.js (UMD_PROD)": { + "size": 22069, + "gzip": 8359 }, - "react-dom-server.development.js (NODE_DEV)": { - "size": 92141, - "gzip": 23593 + "react-dom-server.browser.development.js (NODE_DEV)": { + "size": 92395, + "gzip": 23727 }, - "react-dom-server.production.min.js (NODE_PROD)": { - "size": 21214, - "gzip": 8026 + "react-dom-server.browser.production.min.js (NODE_PROD)": { + "size": 20470, + "gzip": 7751 }, - "ReactDOMServerStream-dev.js (FB_DEV)": { - "size": 264750, - "gzip": 67600 + "ReactDOMServer-dev.js (FB_DEV)": { + "size": 91478, + "gzip": 23641 }, - "ReactDOMServerStream-prod.js (FB_PROD)": { - "size": 198041, - "gzip": 51047 + "ReactDOMServer-prod.js (FB_PROD)": { + "size": 49904, + "gzip": 13944 + }, + "react-dom-server.node.development.js (NODE_DEV)": { + "size": 95082, + "gzip": 24294 + }, + "react-dom-server.node.production.min.js (NODE_PROD)": { + "size": 21375, + "gzip": 8033 }, "react-art.development.js (UMD_DEV)": { - "size": 373050, - "gzip": 82463 + "size": 373020, + "gzip": 82667 }, "react-art.production.min.js (UMD_PROD)": { - "size": 94183, - "gzip": 29145 + "size": 94024, + "gzip": 29099 }, "react-art.development.js (NODE_DEV)": { - "size": 294419, - "gzip": 62436 + "size": 294390, + "gzip": 62633 }, "react-art.production.min.js (NODE_PROD)": { - "size": 55748, - "gzip": 17250 + "size": 55594, + "gzip": 17147 }, "ReactARTFiber-dev.js (FB_DEV)": { - "size": 293279, - "gzip": 62507 + "size": 293221, + "gzip": 62686 }, "ReactARTFiber-prod.js (FB_PROD)": { - "size": 220571, - "gzip": 45660 + "size": 220287, + "gzip": 45716 }, "ReactNativeStack-dev.js (RN_DEV)": { "size": 188445, @@ -121,136 +145,32 @@ "gzip": 26398 }, "ReactNativeFiber-dev.js (RN_DEV)": { - "size": 290148, - "gzip": 52574 + "size": 290448, + "gzip": 52727 }, "ReactNativeFiber-prod.js (RN_PROD)": { - "size": 224144, - "gzip": 38909 + "size": 224421, + "gzip": 39029 }, "react-test-renderer.development.js (NODE_DEV)": { - "size": 291782, - "gzip": 61299 + "size": 292225, + "gzip": 61530 }, "ReactTestRendererFiber-dev.js (FB_DEV)": { - "size": 290600, - "gzip": 61383 + "size": 291017, + "gzip": 61598 }, "react-test-renderer-shallow.development.js (NODE_DEV)": { - "size": 10302, - "gzip": 2587 + "size": 10145, + "gzip": 2581 }, "ReactShallowRenderer-dev.js (FB_DEV)": { - "size": 10208, - "gzip": 2541 + "size": 10051, + "gzip": 2533 }, "react-noop-renderer.development.js (NODE_DEV)": { - "size": 285709, - "gzip": 59710 - }, - "ReactHTMLString-dev.js (FB_DEV)": { - "size": 265654, - "gzip": 67793 - }, - "ReactHTMLString-prod.js (FB_PROD)": { - "size": 197868, - "gzip": 51197 - }, - "react-dom-stream.development.js (UMD_DEV)": { - "size": 307410, - "gzip": 77346 - }, - "react-dom-stream.production.min.js (UMD_PROD)": { - "size": 66444, - "gzip": 22648 - }, - "react-dom-stream.development.js (NODE_DEV)": { - "size": 265257, - "gzip": 67607 - }, - "react-dom-stream.production.min.js (NODE_PROD)": { - "size": 62695, - "gzip": 21279 - }, - "ReactHTMLStream-dev.js (FB_DEV)": { - "size": 264745, - "gzip": 67531 - }, - "ReactHTMLStream-prod.js (FB_PROD)": { - "size": 197512, - "gzip": 50920 - }, - "ReactDOMServer-dev.js (FB_DEV)": { - "size": 91053, - "gzip": 23562 - }, - "ReactDOMServer-prod.js (FB_PROD)": { - "size": 49472, - "gzip": 13857 - }, - "react-dom-node-stream.development.js (NODE_DEV)": { - "size": 93872, - "gzip": 24085 - }, - "react-dom-node-stream.production.min.js (NODE_PROD)": { - "size": 22057, - "gzip": 8338 - }, - "ReactDOMNodeStream-dev.js (FB_DEV)": { - "size": 264918, - "gzip": 67597 - }, - "ReactDOMNodeStream-prod.js (FB_PROD)": { - "size": 197610, - "gzip": 50956 - }, - "react-dom-unstable-native-dependencies.development.js (UMD_DEV)": { - "size": 89486, - "gzip": 22619 - }, - "react-dom-unstable-native-dependencies.production.min.js (UMD_PROD)": { - "size": 18338, - "gzip": 5956 - }, - "react-dom-unstable-native-dependencies.development.js (NODE_DEV)": { - "size": 82914, - "gzip": 20689 - }, - "react-dom-unstable-native-dependencies.production.min.js (NODE_PROD)": { - "size": 16978, - "gzip": 5429 - }, - "ReactDOMUnstableNativeDependencies-dev.js (FB_DEV)": { - "size": 82613, - "gzip": 20656 - }, - "ReactDOMUnstableNativeDependencies-prod.js (FB_PROD)": { - "size": 67256, - "gzip": 16011 - }, - "react-dom-server-browser.development.js (UMD_DEV)": { - "size": 122830, - "gzip": 31052 - }, - "react-dom-server-browser.production.min.js (UMD_PROD)": { - "size": 21723, - "gzip": 8267 - }, - "react-dom-server-browser.development.js (NODE_DEV)": { - "size": 91970, - "gzip": 23650 - }, - "react-dom-server-browser.production.min.js (NODE_PROD)": { - "size": 20124, - "gzip": 7655 - }, - "react-dom-server-node.development.js (NODE_DEV)": { - "size": 93701, - "gzip": 24143 - }, - "react-dom-server-node.production.min.js (NODE_PROD)": { - "size": 20958, - "gzip": 7968 + "size": 286152, + "gzip": 59943 } } } \ No newline at end of file From e17b301dae95afe876b6f784d08aaa1ca1aa65dc Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 3 Aug 2017 00:24:36 +0100 Subject: [PATCH 6/7] Fix the robot nits --- .../ReactServerRenderingBrowser-test.js | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js b/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js index 703e88860db8d..1eee5a1690990 100644 --- a/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js +++ b/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js @@ -12,7 +12,6 @@ 'use strict'; var React; -var ReactDOM; var ReactDOMServer; var ReactDOMServerBrowser; @@ -27,13 +26,15 @@ describe('ReactServerRenderingBrowser', () => { }); it('provides the same top-level API as react-dom/server', () => { - expect(Object.keys(ReactDOMServerBrowser)).toEqual(Object.keys(ReactDOMServer)); + expect(Object.keys(ReactDOMServerBrowser)).toEqual( + Object.keys(ReactDOMServer), + ); }); it('returns the same results as react-dom/server', () => { class Nice extends React.Component { render() { - return

I am feeling very good today, thanks, how are you?

+ return

I am feeling very good today, thanks, how are you?

; } } function Greeting() { @@ -44,31 +45,23 @@ describe('ReactServerRenderingBrowser', () => {
); } - expect( - ReactDOMServerBrowser.renderToString() - ).toEqual( - ReactDOMServer.renderToString() + expect(ReactDOMServerBrowser.renderToString()).toEqual( + ReactDOMServer.renderToString(), ); - expect( - ReactDOMServerBrowser.renderToStaticMarkup() - ).toEqual( - ReactDOMServer.renderToStaticMarkup() + expect(ReactDOMServerBrowser.renderToStaticMarkup()).toEqual( + ReactDOMServer.renderToStaticMarkup(), ); }); if (ReactDOMFeatureFlags.useFiber) { it('throws meaningfully for server-only APIs', () => { - expect(() => - ReactDOMServerBrowser.renderToStream(
) - ).toThrow( + expect(() => ReactDOMServerBrowser.renderToStream(
)).toThrow( 'ReactDOMServer.renderToStream(): The streaming API is not available ' + - 'in the browser. Use ReactDOMServer.renderToString() instead.' + 'in the browser. Use ReactDOMServer.renderToString() instead.', ); - expect(() => - ReactDOMServerBrowser.renderToStaticStream(
) - ).toThrow( + expect(() => ReactDOMServerBrowser.renderToStaticStream(
)).toThrow( 'ReactDOMServer.renderToStaticStream(): The streaming API is not available ' + - 'in the browser. Use ReactDOMServer.renderToStaticMarkup() instead.' + 'in the browser. Use ReactDOMServer.renderToStaticMarkup() instead.', ); }); } From d5200b4798efc84a0e249d0af118b51e608d814d Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 3 Aug 2017 00:26:24 +0100 Subject: [PATCH 7/7] Add resetModules for some extra isolation --- .../dom/shared/__tests__/ReactServerRenderingBrowser-test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js b/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js index 1eee5a1690990..e19c144dcb98f 100644 --- a/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js +++ b/src/renderers/dom/shared/__tests__/ReactServerRenderingBrowser-test.js @@ -22,6 +22,8 @@ describe('ReactServerRenderingBrowser', () => { jest.resetModules(); React = require('react'); ReactDOMServer = require('react-dom/server'); + // For extra isolation between what would be two bundles on npm + jest.resetModuleRegistry(); ReactDOMServerBrowser = require('react-dom/server.browser'); });