Skip to content

Commit

Permalink
Merge /unstable-fizz entry point into /server (#21684)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage authored Jun 15, 2021
1 parent 9343f87 commit 9212d99
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 95 deletions.
2 changes: 1 addition & 1 deletion fixtures/ssr/server/render.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {pipeToNodeWritable} from 'react-dom/unstable-fizz';
import {pipeToNodeWritable} from 'react-dom/server';

import App from '../src/components/App';

Expand Down
14 changes: 12 additions & 2 deletions packages/react-dom/npm/server.browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
'use strict';

var l, s;
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom-server-legacy.browser.production.min.js');
l = require('./cjs/react-dom-server-legacy.browser.production.min.js');
s = require('./cjs/react-dom-server.browser.production.min.js');
} else {
module.exports = require('./cjs/react-dom-server-legacy.browser.development.js');
l = require('./cjs/react-dom-server-legacy.browser.development.js');
s = require('./cjs/react-dom-server.browser.development.js');
}

exports.version = l.version;
exports.renderToString = l.renderToString;
exports.renderToStaticMarkup = l.renderToStaticMarkup;
exports.renderToNodeStream = l.renderToNodeStream;
exports.renderToStaticNodeStream = l.renderToStaticNodeStream;
exports.renderToReadableStream = s.renderToReadableStream;
14 changes: 12 additions & 2 deletions packages/react-dom/npm/server.node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
'use strict';

var l, s;
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom-server-legacy.node.production.min.js');
l = require('./cjs/react-dom-server-legacy.node.production.min.js');
s = require('./cjs/react-dom-server.node.production.min.js');
} else {
module.exports = require('./cjs/react-dom-server-legacy.node.development.js');
l = require('./cjs/react-dom-server-legacy.node.development.js');
s = require('./cjs/react-dom-server.node.development.js');
}

exports.version = l.version;
exports.renderToString = l.renderToString;
exports.renderToStaticMarkup = l.renderToStaticMarkup;
exports.renderToNodeStream = l.renderToNodeStream;
exports.renderToStaticNodeStream = l.renderToStaticNodeStream;
exports.pipeToNodeWritable = s.pipeToNodeWritable;
7 changes: 0 additions & 7 deletions packages/react-dom/npm/unstable-fizz.browser.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/react-dom/npm/unstable-fizz.js

This file was deleted.

7 changes: 0 additions & 7 deletions packages/react-dom/npm/unstable-fizz.node.js

This file was deleted.

6 changes: 1 addition & 5 deletions packages/react-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@
"server.browser.js",
"server.node.js",
"test-utils.js",
"unstable-fizz.js",
"unstable-fizz.browser.js",
"unstable-fizz.node.js",
"cjs/",
"umd/"
],
"browser": {
"./server.js": "./server.browser.js",
"./unstable-fizz.js": "./unstable-fizz.browser.js"
"./server.js": "./server.browser.js"
},
"browserify": {
"transform": [
Expand Down
46 changes: 37 additions & 9 deletions packages/react-dom/server.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,42 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export {
renderToString,
renderToStaticMarkup,
renderToNodeStream,
renderToStaticNodeStream,
version,
} from './src/server/ReactDOMLegacyServerBrowser';
// This file is only used for tests.
// It lazily loads the implementation so that we get the correct set of host configs.

import ReactVersion from 'shared/ReactVersion';
export {ReactVersion as version};

export function renderToString() {
return require('./src/server/ReactDOMLegacyServerBrowser').renderToString.apply(
this,
arguments,
);
}
export function renderToStaticMarkup() {
return require('./src/server/ReactDOMLegacyServerBrowser').renderToStaticMarkup.apply(
this,
arguments,
);
}
export function renderToNodeStream() {
return require('./src/server/ReactDOMLegacyServerBrowser').renderToNodeStream.apply(
this,
arguments,
);
}
export function renderToStaticNodeStream() {
return require('./src/server/ReactDOMLegacyServerBrowser').renderToStaticNodeStream.apply(
this,
arguments,
);
}

export function renderToReadableStream() {
return require('./src/server/ReactDOMFizzServerBrowser').renderToReadableStream.apply(
this,
arguments,
);
}
47 changes: 37 additions & 10 deletions packages/react-dom/server.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,42 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

// 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/ReactDOMLegacyServerNode';
// This file is only used for tests.
// It lazily loads the implementation so that we get the correct set of host configs.

import ReactVersion from 'shared/ReactVersion';
export {ReactVersion as version};

export function renderToString() {
return require('./src/server/ReactDOMLegacyServerNode').renderToString.apply(
this,
arguments,
);
}
export function renderToStaticMarkup() {
return require('./src/server/ReactDOMLegacyServerNode').renderToStaticMarkup.apply(
this,
arguments,
);
}
export function renderToNodeStream() {
return require('./src/server/ReactDOMLegacyServerNode').renderToNodeStream.apply(
this,
arguments,
);
}
export function renderToStaticNodeStream() {
return require('./src/server/ReactDOMLegacyServerNode').renderToStaticNodeStream.apply(
this,
arguments,
);
}

export function pipeToNodeWritable() {
return require('./src/server/ReactDOMFizzServerNode').pipeToNodeWritable.apply(
this,
arguments,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('ReactDOMFizzServer', () => {
React = require('react');
ReactDOM = require('react-dom');
if (__EXPERIMENTAL__) {
ReactDOMFizzServer = require('react-dom/unstable-fizz');
ReactDOMFizzServer = require('react-dom/server');
}
Stream = require('stream');
Suspense = React.Suspense;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('ReactDOMFizzServer', () => {
jest.resetModules();
React = require('react');
if (__EXPERIMENTAL__) {
ReactDOMFizzServer = require('react-dom/unstable-fizz.browser');
ReactDOMFizzServer = require('react-dom/server.browser');
}
Suspense = React.Suspense;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('ReactDOMFizzServer', () => {
jest.resetModules();
React = require('react');
if (__EXPERIMENTAL__) {
ReactDOMFizzServer = require('react-dom/unstable-fizz');
ReactDOMFizzServer = require('react-dom/server');
}
Stream = require('stream');
Suspense = React.Suspense;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ describe('ReactServerRenderingBrowser', () => {
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() {
Expand Down
4 changes: 3 additions & 1 deletion packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import type {ReactNodeList} from 'shared/ReactTypes';

import ReactVersion from 'shared/ReactVersion';

import {
createRequest,
startWork,
Expand Down Expand Up @@ -72,4 +74,4 @@ function renderToReadableStream(
return stream;
}

export {renderToReadableStream};
export {renderToReadableStream, ReactVersion as version};
4 changes: 3 additions & 1 deletion packages/react-dom/src/server/ReactDOMFizzServerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import type {ReactNodeList} from 'shared/ReactTypes';
import type {Writable} from 'stream';

import ReactVersion from 'shared/ReactVersion';

import {
createRequest,
startWork,
Expand Down Expand Up @@ -82,4 +84,4 @@ function pipeToNodeWritable(
};
}

export {pipeToNodeWritable};
export {pipeToNodeWritable, ReactVersion as version};
10 changes: 0 additions & 10 deletions packages/react-dom/unstable-fizz.browser.js

This file was deleted.

10 changes: 0 additions & 10 deletions packages/react-dom/unstable-fizz.js

This file was deleted.

10 changes: 0 additions & 10 deletions packages/react-dom/unstable-fizz.node.js

This file was deleted.

10 changes: 2 additions & 8 deletions scripts/shared/inlinedHostConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ module.exports = [
],
paths: [
'react-dom',
'react-dom/unstable-fizz',
'react-dom/unstable-fizz.node',
'react-dom/src/server/ReactDOMFizzServerNode.js', // react-dom/unstable-fizz.node
'react-dom/src/server/ReactDOMFizzServerNode.js', // react-dom/server.node
'react-server-dom-webpack',
'react-server-dom-webpack/writer',
'react-server-dom-webpack/writer.node.server',
Expand All @@ -43,8 +41,7 @@ module.exports = [
paths: [
'react-dom',
'react-dom/testing',
'react-dom/unstable-fizz.browser',
'react-dom/src/server/ReactDOMFizzServerBrowser.js', // react-dom/unstable-fizz.browser
'react-dom/src/server/ReactDOMFizzServerBrowser.js', // react-dom/server.browser
'react-server-dom-webpack',
'react-server-dom-webpack/writer.browser.server',
'react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js', // react-server-dom-webpack/writer.browser.server
Expand All @@ -61,9 +58,6 @@ module.exports = [
],
paths: [
'react-dom',
'react-dom/server',
'react-dom/server.browser',
'react-dom/server.node',
'react-server-dom-webpack',
'react-dom/src/server/ReactDOMLegacyServerBrowser.js', // react-dom/server.browser
'react-dom/src/server/ReactDOMLegacyServerNode.js', // react-dom/server.node
Expand Down

0 comments on commit 9212d99

Please sign in to comment.