From d827218dad1dd330e8ad4a28846323639edb7b00 Mon Sep 17 00:00:00 2001 From: Matt Travi Date: Sat, 11 Nov 2017 15:36:00 -0600 Subject: [PATCH 1/4] Unfreeze the react-dom/server interface this allows stubbing of the exposed named functions, as was possible before v16.1 fixes #11526 --- packages/react-dom/server.browser.js | 8 +++++++- packages/react-dom/server.node.js | 8 +++++++- packages/react-dom/src/server/ReactDOMServerBrowser.js | 3 ++- packages/react-dom/src/server/ReactDOMServerNode.js | 3 ++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/react-dom/server.browser.js b/packages/react-dom/server.browser.js index ed3636d4c0ee0..fb8e4f06b3d4d 100644 --- a/packages/react-dom/server.browser.js +++ b/packages/react-dom/server.browser.js @@ -9,4 +9,10 @@ 'use strict'; -module.exports = require('./src/server/ReactDOMServerBrowser'); +var ReactDOMServer = require('./src/server/ReactDOMServerBrowser'); + +// TODO: decide on the top-level export form. +// This is hacky but makes it work with both Rollup and Jest +module.exports = ReactDOMServer.default + ? ReactDOMServer.default + : ReactDOMServer; diff --git a/packages/react-dom/server.node.js b/packages/react-dom/server.node.js index 27cd64e7ce9ec..35e73a0d1918e 100644 --- a/packages/react-dom/server.node.js +++ b/packages/react-dom/server.node.js @@ -9,4 +9,10 @@ 'use strict'; -module.exports = require('./src/server/ReactDOMServerNode'); +var ReactDOMServer = require('./src/server/ReactDOMServerNode'); + +// TODO: decide on the top-level export form. +// This is hacky but makes it work with both Rollup and Jest +module.exports = ReactDOMServer.default + ? ReactDOMServer.default + : ReactDOMServer; diff --git a/packages/react-dom/src/server/ReactDOMServerBrowser.js b/packages/react-dom/src/server/ReactDOMServerBrowser.js index cd6f3a61d4c22..4c715e603dfd1 100644 --- a/packages/react-dom/src/server/ReactDOMServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMServerBrowser.js @@ -27,7 +27,8 @@ function renderToStaticNodeStream() { ); } -export { +// Note: when changing this, also consider https://github.com/facebook/react/issues/11526 +export default { renderToString, renderToStaticMarkup, renderToNodeStream, diff --git a/packages/react-dom/src/server/ReactDOMServerNode.js b/packages/react-dom/src/server/ReactDOMServerNode.js index 41ad9422af109..d181f4ce39fd4 100644 --- a/packages/react-dom/src/server/ReactDOMServerNode.js +++ b/packages/react-dom/src/server/ReactDOMServerNode.js @@ -14,7 +14,8 @@ import { renderToStaticNodeStream, } from './ReactDOMNodeStreamRenderer'; -export { +// Note: when changing this, also consider https://github.com/facebook/react/issues/11526 +export default { renderToString, renderToStaticMarkup, renderToNodeStream, From bbd5f77a3c4c0147d26db1a2c1debac0d2a11e6e Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 13 Nov 2017 13:43:05 +0000 Subject: [PATCH 2/4] Fix missing version export --- packages/react-dom/src/server/ReactDOMServerBrowser.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/react-dom/src/server/ReactDOMServerBrowser.js b/packages/react-dom/src/server/ReactDOMServerBrowser.js index 4c715e603dfd1..f4dd6dfa64233 100644 --- a/packages/react-dom/src/server/ReactDOMServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMServerBrowser.js @@ -33,6 +33,5 @@ export default { renderToStaticMarkup, renderToNodeStream, renderToStaticNodeStream, + version: ReactVersion, }; - -export const version = ReactVersion; From b6b15067cabfc4eb82ac42ea453caeed7313b7f5 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 13 Nov 2017 13:43:24 +0000 Subject: [PATCH 3/4] Fix missing version export --- packages/react-dom/src/server/ReactDOMServerNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dom/src/server/ReactDOMServerNode.js b/packages/react-dom/src/server/ReactDOMServerNode.js index d181f4ce39fd4..eb8ce0da3a788 100644 --- a/packages/react-dom/src/server/ReactDOMServerNode.js +++ b/packages/react-dom/src/server/ReactDOMServerNode.js @@ -20,6 +20,6 @@ export default { renderToStaticMarkup, renderToNodeStream, renderToStaticNodeStream, + version: ReactVersion, }; -export const version = ReactVersion; From 2a0fb1767ccc106a8a2bf9402ac464b8c9a3c71d Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 13 Nov 2017 13:44:37 +0000 Subject: [PATCH 4/4] Whitespace --- packages/react-dom/src/server/ReactDOMServerNode.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react-dom/src/server/ReactDOMServerNode.js b/packages/react-dom/src/server/ReactDOMServerNode.js index eb8ce0da3a788..015ba082fdcb9 100644 --- a/packages/react-dom/src/server/ReactDOMServerNode.js +++ b/packages/react-dom/src/server/ReactDOMServerNode.js @@ -22,4 +22,3 @@ export default { renderToStaticNodeStream, version: ReactVersion, }; -