Skip to content

Commit 00e84f0

Browse files
committed
Add IIFE bundle for SSR instruction streaming runtime
1 parent aa9988e commit 00e84f0

File tree

7 files changed

+126
-4
lines changed

7 files changed

+126
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// SSR instruction streaming runtime
2+
// will be added by https://github.com/facebook/react/pull/25437

packages/react-dom/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"index.js",
3030
"client.js",
3131
"profiling.js",
32+
"external-streaming-runtime.js",
3233
"server.js",
3334
"server.browser.js",
3435
"server.node.js",
@@ -39,7 +40,8 @@
3940
"test-utils.js",
4041
"unstable_testing.js",
4142
"cjs/",
42-
"umd/"
43+
"umd/",
44+
"iife/"
4345
],
4446
"exports": {
4547
".": "./index.js",
@@ -61,6 +63,7 @@
6163
"./static.browser": "./static.browser.js",
6264
"./static.node": "./static.node.js",
6365
"./server-rendering-stub": "./server-rendering-stub.js",
66+
"./external-streaming-runtime": "./external-streaming-runtime.js",
6467
"./profiling": "./profiling.js",
6568
"./test-utils": "./test-utils.js",
6669
"./unstable_testing": "./unstable_testing.js",

scripts/rollup/build.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ const {
6060
RN_FB_DEV,
6161
RN_FB_PROD,
6262
RN_FB_PROFILING,
63+
IIFE_DEV,
64+
IIFE_PROD,
65+
FB_IIFE_DEV,
66+
FB_IIFE_PROD,
6367
} = Bundles.bundleTypes;
6468

6569
const {getFilename} = Bundles;
@@ -224,6 +228,11 @@ function getFormat(bundleType) {
224228
return `cjs`;
225229
case NODE_ESM:
226230
return `es`;
231+
case IIFE_DEV:
232+
case IIFE_PROD:
233+
case FB_IIFE_DEV:
234+
case FB_IIFE_PROD:
235+
return 'iife';
227236
}
228237
}
229238

@@ -236,6 +245,8 @@ function isProductionBundleType(bundleType) {
236245
case FB_WWW_DEV:
237246
case RN_OSS_DEV:
238247
case RN_FB_DEV:
248+
case IIFE_DEV:
249+
case FB_IIFE_DEV:
239250
return false;
240251
case UMD_PROD:
241252
case NODE_PROD:
@@ -247,6 +258,8 @@ function isProductionBundleType(bundleType) {
247258
case RN_OSS_PROFILING:
248259
case RN_FB_PROD:
249260
case RN_FB_PROFILING:
261+
case IIFE_PROD:
262+
case FB_IIFE_PROD:
250263
return true;
251264
default:
252265
throw new Error(`Unknown type: ${bundleType}`);
@@ -267,6 +280,10 @@ function isProfilingBundleType(bundleType) {
267280
case RN_OSS_PROD:
268281
case UMD_DEV:
269282
case UMD_PROD:
283+
case IIFE_DEV:
284+
case IIFE_PROD:
285+
case FB_IIFE_DEV:
286+
case FB_IIFE_PROD:
270287
return false;
271288
case FB_WWW_PROFILING:
272289
case NODE_PROFILING:
@@ -315,7 +332,9 @@ function getPlugins(
315332
const isFBWWWBundle =
316333
bundleType === FB_WWW_DEV ||
317334
bundleType === FB_WWW_PROD ||
318-
bundleType === FB_WWW_PROFILING;
335+
bundleType === FB_WWW_PROFILING ||
336+
bundleType === FB_IIFE_DEV ||
337+
bundleType === FB_IIFE_PROD;
319338
const isRNBundle =
320339
bundleType === RN_OSS_DEV ||
321340
bundleType === RN_OSS_PROD ||
@@ -509,7 +528,9 @@ async function createBundle(bundle, bundleType) {
509528
const isFBWWWBundle =
510529
bundleType === FB_WWW_DEV ||
511530
bundleType === FB_WWW_PROD ||
512-
bundleType === FB_WWW_PROFILING;
531+
bundleType === FB_WWW_PROFILING ||
532+
bundleType === FB_IIFE_DEV ||
533+
bundleType === FB_IIFE_PROD;
513534

514535
const isFBRNBundle =
515536
bundleType === RN_FB_DEV ||
@@ -593,6 +614,7 @@ async function createBundle(bundle, bundleType) {
593614
bundle.global,
594615
bundleType
595616
);
617+
console.log(rollupOutputOptions);
596618

597619
if (isWatchMode) {
598620
rollupConfig.output = [rollupOutputOptions];
@@ -724,7 +746,11 @@ async function buildEverything() {
724746
[bundle, RN_OSS_PROFILING],
725747
[bundle, RN_FB_DEV],
726748
[bundle, RN_FB_PROD],
727-
[bundle, RN_FB_PROFILING]
749+
[bundle, RN_FB_PROFILING],
750+
[bundle, IIFE_DEV],
751+
[bundle, IIFE_PROD],
752+
[bundle, FB_IIFE_DEV],
753+
[bundle, FB_IIFE_PROD]
728754
);
729755
}
730756

scripts/rollup/bundles.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const bundleTypes = {
2525
RN_FB_DEV: 'RN_FB_DEV',
2626
RN_FB_PROD: 'RN_FB_PROD',
2727
RN_FB_PROFILING: 'RN_FB_PROFILING',
28+
IIFE_DEV: 'IIFE_DEV',
29+
IIFE_PROD: 'IIFE_PROD',
30+
FB_IIFE_DEV: 'FB_IIFE_DEV',
31+
FB_IIFE_PROD: 'FB_IIFE_PROD',
2832
};
2933

3034
const {
@@ -45,6 +49,10 @@ const {
4549
RN_FB_DEV,
4650
RN_FB_PROD,
4751
RN_FB_PROFILING,
52+
IIFE_DEV,
53+
IIFE_PROD,
54+
FB_IIFE_DEV,
55+
FB_IIFE_PROD,
4856
} = bundleTypes;
4957

5058
const moduleTypes = {
@@ -330,6 +338,19 @@ const bundles = [
330338
externals: ['react', 'react-dom'],
331339
},
332340

341+
{
342+
bundleTypes: __EXPERIMENTAL__
343+
? [IIFE_DEV, IIFE_PROD, FB_IIFE_DEV, FB_IIFE_PROD]
344+
: [],
345+
moduleType: RENDERER,
346+
entry: 'react-dom/external-streaming-runtime',
347+
name: 'external-streaming-runtime',
348+
global: 'ReactDOMExternalStreamingRuntime',
349+
minifyWithProdErrorCodes: true,
350+
wrapWithModuleBoundaries: false,
351+
externals: [],
352+
},
353+
333354
/******* React DOM Fizz Static *******/
334355
{
335356
bundleTypes: __EXPERIMENTAL__ ? [NODE_DEV, NODE_PROD] : [],
@@ -1006,6 +1027,8 @@ function getOriginalFilename(bundle, bundleType) {
10061027
return `${name}.js`;
10071028
case NODE_ESM:
10081029
return `${name}.js`;
1030+
case IIFE_DEV:
1031+
return `${name}.development.js`;
10091032
case UMD_DEV:
10101033
return `${name}.development.js`;
10111034
case UMD_PROD:
@@ -1018,13 +1041,17 @@ function getOriginalFilename(bundle, bundleType) {
10181041
return `${name}.production.min.js`;
10191042
case NODE_PROFILING:
10201043
return `${name}.profiling.min.js`;
1044+
case IIFE_PROD:
1045+
return `${name}.production.min.js`;
10211046
case FB_WWW_DEV:
10221047
case RN_OSS_DEV:
10231048
case RN_FB_DEV:
1049+
case FB_IIFE_DEV:
10241050
return `${globalName}-dev.js`;
10251051
case FB_WWW_PROD:
10261052
case RN_OSS_PROD:
10271053
case RN_FB_PROD:
1054+
case FB_IIFE_PROD:
10281055
return `${globalName}-prod.js`;
10291056
case FB_WWW_PROFILING:
10301057
case RN_FB_PROFILING:

scripts/rollup/packaging.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const {
3333
RN_FB_DEV,
3434
RN_FB_PROD,
3535
RN_FB_PROFILING,
36+
IIFE_DEV,
37+
IIFE_PROD,
38+
FB_IIFE_DEV,
39+
FB_IIFE_PROD,
3640
} = Bundles.bundleTypes;
3741

3842
function getPackageName(name) {
@@ -59,6 +63,8 @@ function getBundleOutputPath(bundleType, filename, packageName) {
5963
case FB_WWW_DEV:
6064
case FB_WWW_PROD:
6165
case FB_WWW_PROFILING:
66+
case FB_IIFE_DEV:
67+
case FB_IIFE_PROD:
6268
return `build/facebook-www/${filename}`;
6369
case RN_OSS_DEV:
6470
case RN_OSS_PROD:
@@ -88,6 +94,9 @@ function getBundleOutputPath(bundleType, filename, packageName) {
8894
default:
8995
throw new Error('Unknown RN package.');
9096
}
97+
case IIFE_DEV:
98+
case IIFE_PROD:
99+
return `build/node_modules/${packageName}/iife/${filename}`;
91100
default:
92101
throw new Error('Unknown bundle type.');
93102
}

scripts/rollup/wrappers.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ const {
2222
RN_FB_DEV,
2323
RN_FB_PROD,
2424
RN_FB_PROFILING,
25+
IIFE_DEV,
26+
IIFE_PROD,
27+
FB_IIFE_DEV,
28+
FB_IIFE_PROD,
2529
} = bundleTypes;
2630

2731
const {RECONCILER} = moduleTypes;
@@ -294,6 +298,55 @@ ${license}
294298
* ${'@gen' + 'erated'}
295299
*/
296300
301+
${source}`;
302+
},
303+
304+
[IIFE_DEV](source, globalName, filename, moduleType) {
305+
return `/**
306+
* @license React
307+
* ${filename}
308+
*
309+
${license}
310+
*/
311+
${source}`;
312+
},
313+
[IIFE_PROD](source, globalName, filename, moduleType) {
314+
return `/**
315+
* @license React
316+
* ${filename}
317+
*
318+
${license}
319+
*/
320+
${source}`;
321+
},
322+
[FB_IIFE_DEV](source, globalName, filename, moduleType) {
323+
return `/**
324+
${license}
325+
*
326+
* @noflow
327+
* @nolint
328+
* @preventMunge
329+
* @preserve-invariant-messages
330+
*/
331+
332+
'use strict';
333+
334+
if (__DEV__) {
335+
(function() {
336+
${source}
337+
})();
338+
}`;
339+
},
340+
[FB_IIFE_PROD](source, globalName, filename, moduleType) {
341+
return `/**
342+
${license}
343+
*
344+
* @noflow
345+
* @nolint
346+
* @preventMunge
347+
* @preserve-invariant-messages
348+
*/
349+
297350
${source}`;
298351
},
299352
};

scripts/shared/inlinedHostConfigs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = [
1515
'react-dom/src/server/ReactDOMFizzServerNode.js',
1616
'react-dom/static.node',
1717
'react-dom/server-rendering-stub',
18+
'react-dom/external-streaming-runtime',
1819
'react-server-dom-webpack/writer.node.server',
1920
'react-server-dom-webpack',
2021
],
@@ -51,6 +52,7 @@ module.exports = [
5152
'react-dom/src/server/ReactDOMFizzServerBrowser.js',
5253
'react-dom/static.browser',
5354
'react-dom/server-rendering-stub',
55+
'react-dom/external-streaming-runtime',
5456
'react-server-dom-webpack/writer.browser.server',
5557
'react-server-dom-webpack',
5658
],

0 commit comments

Comments
 (0)