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

Convert the rest of react-dom and react-test-renderer to Named Exports #18145

Merged
merged 1 commit into from
Feb 27, 2020
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
14 changes: 7 additions & 7 deletions packages/react-dom/server.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
* @flow
*/

'use strict';

const 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;
export {
renderToString,
renderToStaticMarkup,
renderToNodeStream,
renderToStaticNodeStream,
version,
} from './src/server/ReactDOMServerBrowser';
4 changes: 1 addition & 3 deletions packages/react-dom/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
* @flow
*/

'use strict';

module.exports = require('./server.node');
export * from './server.node';
15 changes: 8 additions & 7 deletions packages/react-dom/server.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
* @flow
*/

'use strict';

const 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;
// For some reason Flow doesn't like export * in this file. I don't know why.
export {
renderToString,
renderToStaticMarkup,
renderToNodeStream,
renderToStaticNodeStream,
version,
} from './src/server/ReactDOMServerNode';
20 changes: 6 additions & 14 deletions packages/react-dom/src/__tests__/ReactTestUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

'use strict';

let createRenderer;
let React;
let ReactDOM;
let ReactDOMServer;
let ReactTestUtils;
import ReactShallowRenderer from 'react-test-renderer/shallow';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as ReactDOMServer from 'react-dom/server';
import * as ReactTestUtils from 'react-dom/test-utils';
gaearon marked this conversation as resolved.
Show resolved Hide resolved

function getTestDocument(markup) {
const doc = document.implementation.createHTMLDocument('');
Expand All @@ -27,14 +27,6 @@ function getTestDocument(markup) {
}

describe('ReactTestUtils', () => {
beforeEach(() => {
createRenderer = require('react-test-renderer/shallow').createRenderer;
React = require('react');
ReactDOM = require('react-dom');
ReactDOMServer = require('react-dom/server');
ReactTestUtils = require('react-dom/test-utils');
});

it('Simulate should have locally attached media events', () => {
expect(Object.keys(ReactTestUtils.Simulate).sort()).toMatchSnapshot();
});
Expand Down Expand Up @@ -403,7 +395,7 @@ describe('ReactTestUtils', () => {
}

const handler = jest.fn().mockName('spy');
const shallowRenderer = createRenderer();
const shallowRenderer = ReactShallowRenderer.createRenderer();
const result = shallowRenderer.render(
<SomeComponent handleClick={handler} />,
);
Expand Down
4 changes: 1 addition & 3 deletions packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@ function renderToReadableStream(children: ReactNodeList): ReadableStream {
});
}

export default {
renderToReadableStream,
};
export {renderToReadableStream};
4 changes: 1 addition & 3 deletions packages/react-dom/src/server/ReactDOMFizzServerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ function pipeToNodeWritable(
startWork(request);
}

export default {
pipeToNodeWritable,
};
export {pipeToNodeWritable};
5 changes: 2 additions & 3 deletions packages/react-dom/src/server/ReactDOMServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ function renderToStaticNodeStream() {
);
}

// Note: when changing this, also consider https://github.com/facebook/react/issues/11526
export default {
export {
renderToString,
renderToStaticMarkup,
renderToNodeStream,
renderToStaticNodeStream,
version: ReactVersion,
ReactVersion as version,
};
5 changes: 2 additions & 3 deletions packages/react-dom/src/server/ReactDOMServerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import {
renderToStaticNodeStream,
} from './ReactDOMNodeStreamRenderer';

// Note: when changing this, also consider https://github.com/facebook/react/issues/11526
export default {
export {
renderToString,
renderToStaticMarkup,
renderToNodeStream,
renderToStaticNodeStream,
version: ReactVersion,
ReactVersion as version,
};
Loading