Skip to content

Commit

Permalink
Expose resume() API but not in stable
Browse files Browse the repository at this point in the history
Since we don't have a top level module for these we have to introduce one
that we can fork.
  • Loading branch information
sebmarkbage committed Aug 22, 2023
1 parent f40d58b commit 2072780
Show file tree
Hide file tree
Showing 21 changed files with 154 additions and 19 deletions.
3 changes: 3 additions & 0 deletions packages/react-dom/npm/server.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ exports.renderToStaticMarkup = l.renderToStaticMarkup;
exports.renderToNodeStream = l.renderToNodeStream;
exports.renderToStaticNodeStream = l.renderToStaticNodeStream;
exports.renderToReadableStream = s.renderToReadableStream;
if (s.resume) {
exports.resume = s.resume;
}
3 changes: 3 additions & 0 deletions packages/react-dom/npm/server.bun.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ if (process.env.NODE_ENV === 'production') {

exports.version = b.version;
exports.renderToReadableStream = b.renderToReadableStream;
if (b.resume) {
exports.resume = b.resume;
}
exports.renderToNodeStream = b.renderToNodeStream;
exports.renderToStaticNodeStream = b.renderToStaticNodeStream;
exports.renderToString = l.renderToString;
Expand Down
3 changes: 3 additions & 0 deletions packages/react-dom/npm/server.edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ exports.renderToNodeStream = b.renderToNodeStream;
exports.renderToStaticNodeStream = b.renderToStaticNodeStream;
exports.renderToString = l.renderToString;
exports.renderToStaticMarkup = l.renderToStaticMarkup;
if (b.resume) {
exports.resume = b.resume;
}
3 changes: 3 additions & 0 deletions packages/react-dom/npm/server.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ exports.renderToStaticMarkup = l.renderToStaticMarkup;
exports.renderToNodeStream = l.renderToNodeStream;
exports.renderToStaticNodeStream = l.renderToStaticNodeStream;
exports.renderToPipeableStream = s.renderToPipeableStream;
if (s.resume) {
exports.resume = s.resume;
}
9 changes: 8 additions & 1 deletion packages/react-dom/server.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ export function renderToStaticNodeStream() {
}

export function renderToReadableStream() {
return require('./src/server/ReactDOMFizzServerBrowser').renderToReadableStream.apply(
return require('./src/server/react-dom-server.browser').renderToReadableStream.apply(
this,
arguments,
);
}

export function resume() {
return require('./src/server/react-dom-server.browser').resume.apply(
this,
arguments,
);
Expand Down
13 changes: 10 additions & 3 deletions packages/react-dom/server.bun.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import ReactVersion from 'shared/ReactVersion';
export {ReactVersion as version};

export function renderToReadableStream() {
return require('./src/server/ReactDOMFizzServerBun').renderToReadableStream.apply(
return require('./src/server/react-dom-server.bun').renderToReadableStream.apply(
this,
arguments,
);
}

export function renderToNodeStream() {
return require('./src/server/ReactDOMFizzServerBun').renderToNodeStream.apply(
return require('./src/server/react-dom-server.bun').renderToNodeStream.apply(
this,
arguments,
);
}

export function renderToStaticNodeStream() {
return require('./src/server/ReactDOMFizzServerBun').renderToStaticNodeStream.apply(
return require('./src/server/react-dom-server.bun').renderToStaticNodeStream.apply(
this,
arguments,
);
Expand All @@ -45,3 +45,10 @@ export function renderToStaticMarkup() {
arguments,
);
}

export function resume() {
return require('./src/server/react-dom-server.bun').resume.apply(
this,
arguments,
);
}
13 changes: 10 additions & 3 deletions packages/react-dom/server.edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import ReactVersion from 'shared/ReactVersion';
export {ReactVersion as version};

export function renderToReadableStream() {
return require('./src/server/ReactDOMFizzServerEdge').renderToReadableStream.apply(
return require('./src/server/react-dom-server.edge').renderToReadableStream.apply(
this,
arguments,
);
}

export function renderToNodeStream() {
return require('./src/server/ReactDOMFizzServerEdge').renderToNodeStream.apply(
return require('./src/server/react-dom-server.edge').renderToNodeStream.apply(
this,
arguments,
);
}

export function renderToStaticNodeStream() {
return require('./src/server/ReactDOMFizzServerEdge').renderToStaticNodeStream.apply(
return require('./src/server/react-dom-server.edge').renderToStaticNodeStream.apply(
this,
arguments,
);
Expand All @@ -45,3 +45,10 @@ export function renderToStaticMarkup() {
arguments,
);
}

export function resume() {
return require('./src/server/react-dom-server.edge').resume.apply(
this,
arguments,
);
}
9 changes: 8 additions & 1 deletion packages/react-dom/server.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ export function renderToStaticNodeStream() {
}

export function renderToPipeableStream() {
return require('./src/server/ReactDOMFizzServerNode').renderToPipeableStream.apply(
return require('./src/server/react-dom-server.node').renderToPipeableStream.apply(
this,
arguments,
);
}

export function resume() {
return require('./src/server/react-dom-server.node').resume.apply(
this,
arguments,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,4 @@ function resume(
});
}

export {renderToReadableStream, ReactVersion as version};
export {renderToReadableStream, resume, ReactVersion as version};
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/ReactDOMFizzServerEdge.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,4 @@ function resume(
});
}

export {renderToReadableStream, ReactVersion as version};
export {renderToReadableStream, resume, ReactVersion as version};
6 changes: 5 additions & 1 deletion packages/react-dom/src/server/ReactDOMFizzServerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,8 @@ function resumeToPipeableStream(
};
}

export {renderToPipeableStream, ReactVersion as version};
export {
renderToPipeableStream,
resumeToPipeableStream,
ReactVersion as version,
};
10 changes: 10 additions & 0 deletions packages/react-dom/src/server/react-dom-server.browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './ReactDOMFizzServerBrowser.js';
10 changes: 10 additions & 0 deletions packages/react-dom/src/server/react-dom-server.browser.stable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export {renderToReadableStream, version} from './ReactDOMFizzServerBrowser.js';
10 changes: 10 additions & 0 deletions packages/react-dom/src/server/react-dom-server.bun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './ReactDOMFizzServerBun.js';
15 changes: 15 additions & 0 deletions packages/react-dom/src/server/react-dom-server.bun.stable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export {
renderToReadableStream,
renderToNodeStream,
renderToStaticNodeStream,
version,
} from './ReactDOMFizzServerBun.js';
10 changes: 10 additions & 0 deletions packages/react-dom/src/server/react-dom-server.edge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './ReactDOMFizzServerEdge.js';
10 changes: 10 additions & 0 deletions packages/react-dom/src/server/react-dom-server.edge.stable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export {renderToReadableStream, version} from './ReactDOMFizzServerEdge.js';
10 changes: 10 additions & 0 deletions packages/react-dom/src/server/react-dom-server.node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './ReactDOMFizzServerNode.js';
10 changes: 10 additions & 0 deletions packages/react-dom/src/server/react-dom-server.node.stable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export {renderToPipeableStream, version} from './ReactDOMFizzServerNode.js';
8 changes: 4 additions & 4 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ const bundles = [
{
bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
moduleType: RENDERER,
entry: 'react-dom/src/server/ReactDOMFizzServerBrowser.js',
entry: 'react-dom/src/server/react-dom-server.browser.js',
name: 'react-dom-server.browser',
global: 'ReactDOMServer',
minifyWithProdErrorCodes: true,
Expand All @@ -243,7 +243,7 @@ const bundles = [
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RENDERER,
entry: 'react-dom/src/server/ReactDOMFizzServerNode.js',
entry: 'react-dom/src/server/react-dom-server.node.js',
name: 'react-dom-server.node',
global: 'ReactDOMServer',
minifyWithProdErrorCodes: false,
Expand All @@ -264,7 +264,7 @@ const bundles = [
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RENDERER,
entry: 'react-dom/src/server/ReactDOMFizzServerEdge.js',
entry: 'react-dom/src/server/react-dom-server.edge.js',
name: 'react-dom-server.edge', // 'node_modules/react/*.js',

global: 'ReactDOMServer',
Expand All @@ -277,7 +277,7 @@ const bundles = [
{
bundleTypes: [BUN_DEV, BUN_PROD],
moduleType: RENDERER,
entry: 'react-dom/src/server/ReactDOMFizzServerBun.js',
entry: 'react-dom/src/server/react-dom-server.bun.js',
name: 'react-dom-server.bun', // 'node_modules/react/*.js',

global: 'ReactDOMServer',
Expand Down
14 changes: 10 additions & 4 deletions scripts/shared/inlinedHostConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = [
entryPoints: [
'react-dom',
'react-dom/unstable_testing',
'react-dom/src/server/ReactDOMFizzServerNode.js',
'react-dom/src/server/react-dom-server.node.js',
'react-dom/static.node',
'react-dom/server-rendering-stub',
'react-dom/unstable_server-external-runtime',
Expand All @@ -27,6 +27,7 @@ module.exports = [
'react-dom/server.node',
'react-dom/static',
'react-dom/static.node',
'react-dom/src/server/react-dom-server.node',
'react-dom/src/server/ReactDOMFizzServerNode.js', // react-dom/server.node
'react-dom/src/server/ReactDOMFizzStaticNode.js',
'react-server-dom-webpack',
Expand All @@ -46,10 +47,11 @@ module.exports = [
},
{
shortName: 'dom-bun',
entryPoints: ['react-dom', 'react-dom/src/server/ReactDOMFizzServerBun.js'],
entryPoints: ['react-dom', 'react-dom/src/server/react-dom-server.bun.js'],
paths: [
'react-dom',
'react-dom/server.bun',
'react-dom/src/server/react-dom-server.bun',
'react-dom/src/server/ReactDOMFizzServerBun.js',
'react-dom-bindings',
'shared/ReactDOMSharedInternals',
Expand All @@ -62,7 +64,7 @@ module.exports = [
entryPoints: [
'react-dom',
'react-dom/unstable_testing',
'react-dom/src/server/ReactDOMFizzServerBrowser.js',
'react-dom/src/server/react-dom-server.browser.js',
'react-dom/static.browser',
'react-dom/server-rendering-stub',
'react-dom/unstable_server-external-runtime',
Expand All @@ -76,6 +78,7 @@ module.exports = [
'react-dom/server.browser',
'react-dom/static.browser',
'react-dom/unstable_testing',
'react-dom/src/server/react-dom-server.browser',
'react-dom/src/server/ReactDOMFizzServerBrowser.js', // react-dom/server.browser
'react-dom/src/server/ReactDOMFizzStaticBrowser.js',
'react-server-dom-webpack',
Expand Down Expand Up @@ -118,7 +121,7 @@ module.exports = [
{
shortName: 'dom-edge-webpack',
entryPoints: [
'react-dom/src/server/ReactDOMFizzServerEdge.js',
'react-dom/src/server/react-dom-server.edge.js',
'react-dom/static.edge',
'react-server-dom-webpack/server.edge',
'react-server-dom-webpack/client.edge',
Expand All @@ -130,6 +133,7 @@ module.exports = [
'react-dom/server.edge',
'react-dom/static.edge',
'react-dom/unstable_testing',
'react-dom/src/server/react-dom-server.edge',
'react-dom/src/server/ReactDOMFizzServerEdge.js', // react-dom/server.edge
'react-dom/src/server/ReactDOMFizzStaticEdge.js',
'react-server-dom-webpack',
Expand Down Expand Up @@ -160,6 +164,7 @@ module.exports = [
'react-dom/server.node',
'react-dom/static',
'react-dom/static.node',
'react-dom/src/server/react-dom-server.node',
'react-dom/src/server/ReactDOMFizzServerNode.js', // react-dom/server.node
'react-dom/src/server/ReactDOMFizzStaticNode.js',
'react-server-dom-webpack',
Expand Down Expand Up @@ -193,6 +198,7 @@ module.exports = [
'react-dom/server.node',
'react-dom/static',
'react-dom/static.node',
'react-dom/src/server/react-dom-server.node',
'react-dom/src/server/ReactDOMFizzServerNode.js', // react-dom/server.node
'react-dom/src/server/ReactDOMFizzStaticNode.js',
'react-server-dom-esm',
Expand Down

0 comments on commit 2072780

Please sign in to comment.