Skip to content

Commit 32d2e87

Browse files
committed
Build a Node.js Web Streams bundled for unbundled server
1 parent 061a6e7 commit 32d2e87

File tree

7 files changed

+109
-6
lines changed

7 files changed

+109
-6
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
export {default as rendererVersion} from 'shared/ReactVersion';
11+
export const rendererPackageName = 'react-server-dom-webpack';
12+
13+
export * from 'react-client/src/ReactFlightClientStreamConfigWeb';
14+
export * from 'react-client/src/ReactClientConsoleConfigServer';
15+
export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerNode';
16+
export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigTargetWebpackServer';
17+
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
18+
export const usedWithSSR = true;
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
'use strict';
22

3+
var n, w;
34
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-server-dom-webpack-client.node.unbundled.production.js');
5+
n = require('./cjs/react-server-dom-webpack-client.node.unbundled.production.js');
6+
w = require('./cjs/react-server-dom-webpack-client.node-webstreams.unbundled.production.js');
57
} else {
6-
module.exports = require('./cjs/react-server-dom-webpack-client.node.unbundled.development.js');
8+
n = require('./cjs/react-server-dom-webpack-client.node.unbundled.development.js');
9+
w = require('./cjs/react-server-dom-webpack-client.node-webstreams.unbundled.development.js');
710
}
11+
12+
exports.registerServerReference = function (r, i, e) {
13+
return w.registerServerReference(n.registerServerReference(r, i, e), i, e);
14+
};
15+
exports.createServerReference = function (i, c, e, d, f) {
16+
return w.registerServerReference(
17+
n.createServerReference(i, c, e, d, f),
18+
i,
19+
e
20+
);
21+
};
22+
23+
exports.createFromNodeStream = n.createFromNodeStream;
24+
exports.createFromFetch = w.createFromFetch;
25+
exports.createFromReadableStream = w.createFromReadableStream;
26+
27+
exports.createTemporaryReferenceSet = w.createTemporaryReferenceSet;
28+
exports.encodeReply = w.encodeReply;

packages/react-server-dom-webpack/npm/server.node.unbundled.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use strict';
22

3-
var s;
3+
var s, w;
44
if (process.env.NODE_ENV === 'production') {
55
s = require('./cjs/react-server-dom-webpack-server.node.unbundled.production.js');
6+
w = require('./cjs/react-server-dom-webpack-server.node-webstreams.unbundled.production.js');
67
} else {
78
s = require('./cjs/react-server-dom-webpack-server.node.unbundled.development.js');
9+
w = require('./cjs/react-server-dom-webpack-server.node-webstreams.unbundled.development.js');
810
}
911

1012
exports.renderToPipeableStream = s.renderToPipeableStream;
@@ -16,3 +18,6 @@ exports.registerServerReference = s.registerServerReference;
1618
exports.registerClientReference = s.registerClientReference;
1719
exports.createClientModuleProxy = s.createClientModuleProxy;
1820
exports.createTemporaryReferenceSet = s.createTemporaryReferenceSet;
21+
22+
exports.renderToReadableStream = w.renderToReadableStream;
23+
exports.decodeReplyFromAsyncIterable = w.decodeReplyFromAsyncIterable;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
export * from './ReactFlightDOMClientEdge';
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
export {
11+
renderToReadableStream,
12+
prerender as unstable_prerender,
13+
decodeReply,
14+
decodeReplyFromAsyncIterable,
15+
decodeAction,
16+
decodeFormState,
17+
registerServerReference,
18+
registerClientReference,
19+
createClientModuleProxy,
20+
createTemporaryReferenceSet,
21+
} from './ReactFlightDOMServerEdge';

scripts/rollup/bundles.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,18 @@ const bundles = [
484484
wrapWithModuleBoundaries: false,
485485
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'],
486486
},
487+
{
488+
bundleTypes: [NODE_DEV, NODE_PROD],
489+
moduleType: RENDERER,
490+
entry:
491+
'react-server-dom-webpack/src/server/react-flight-dom-server.node-webstreams.unbundled',
492+
name: 'react-server-dom-webpack-server.node-webstreams.unbundled',
493+
condition: 'react-server',
494+
global: 'ReactServerDOMServer',
495+
minifyWithProdErrorCodes: false,
496+
wrapWithModuleBoundaries: false,
497+
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'],
498+
},
487499
{
488500
bundleTypes: [NODE_DEV, NODE_PROD],
489501
moduleType: RENDERER,
@@ -529,6 +541,17 @@ const bundles = [
529541
wrapWithModuleBoundaries: false,
530542
externals: ['react', 'react-dom', 'util', 'crypto'],
531543
},
544+
{
545+
bundleTypes: [NODE_DEV, NODE_PROD],
546+
moduleType: RENDERER,
547+
entry:
548+
'react-server-dom-webpack/src/client/react-flight-dom-client.node-webstreams.unbundled',
549+
name: 'react-server-dom-webpack-client.node-webstreams.unbundled',
550+
global: 'ReactServerDOMClient',
551+
minifyWithProdErrorCodes: false,
552+
wrapWithModuleBoundaries: false,
553+
externals: ['react', 'react-dom', 'util', 'crypto'],
554+
},
532555
{
533556
bundleTypes: [NODE_DEV, NODE_PROD],
534557
moduleType: RENDERER,

scripts/shared/inlinedHostConfigs.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ module.exports = [
106106
},
107107
{
108108
shortName: 'dom-node-webstreams',
109-
entryPoints: ['react-dom/src/server/react-dom-server.node-webstreams.js'],
109+
entryPoints: [
110+
'react-dom/src/server/react-dom-server.node-webstreams.js',
111+
'react-server-dom-webpack/src/client/react-flight-dom-client.node-webstreams.unbundled',
112+
'react-server-dom-webpack/src/server/react-flight-dom-server.node-webstreams.unbundled',
113+
],
110114
paths: [
111115
'react-dom',
112116
'react-dom/src/ReactDOMReactServer.js',
@@ -123,7 +127,7 @@ module.exports = [
123127
'react-dom/src/server/ReactDOMFizzStaticEdge.js',
124128
'react-dom-bindings/src/server/ReactDOMFlightServerHostDispatcher.js',
125129
'react-dom-bindings/src/server/ReactFlightServerConfigDOM.js',
126-
'react-dom-bindins/src/shared/ReactFlightClientConfigDOM.js',
130+
'react-dom-bindings/src/shared/ReactFlightClientConfigDOM.js',
127131
'react-server-dom-webpack',
128132
'react-server-dom-webpack/client.node.unbundled',
129133
'react-server-dom-webpack/server',
@@ -132,7 +136,8 @@ module.exports = [
132136
'react-server-dom-webpack/static.node.unbundled',
133137
'react-server-dom-webpack/src/client/ReactFlightDOMClientEdge.js', // react-server-dom-webpack/client.node
134138
'react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerNode.js',
135-
'react-server-dom-webpack/src/server/react-flight-dom-server.node.unbundled',
139+
'react-server-dom-webpack/src/client/react-flight-dom-client.node-webstreams.unbundled',
140+
'react-server-dom-webpack/src/server/react-flight-dom-server.node-webstreams.unbundled',
136141
'react-server-dom-webpack/src/server/ReactFlightDOMServerEdge.js', // react-server-dom-webpack/src/server/react-flight-dom-server.node
137142
'shared/ReactDOMSharedInternals',
138143
'react-server/src/ReactFlightServerConfigDebugNode.js',

0 commit comments

Comments
 (0)