Skip to content

Commit

Permalink
[Static][Fizz] Carry forward bootstrap config to resume if postponing…
Browse files Browse the repository at this point in the history
… in the shell (#27672)

Previously it was possible to postpone in the shell during a prerender
and then during a resume the bootstrap scripts would not be emitted
leading to no hydration on the client. This change moves the bootstrap
configuration to `ResumableState` where it can be serialized after
postponing if it wasn't flushed as part of the static shell.

DiffTrain build for [7508dcd](7508dcd)
  • Loading branch information
gnoff committed Nov 8, 2023
1 parent 0367178 commit 6e10ef7
Show file tree
Hide file tree
Showing 9 changed files with 479 additions and 182 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
88b00dec4778ffa230cceca81af3328f49e1efd9
7508dcd5cc245e376860d65402972e418199264d
2 changes: 1 addition & 1 deletion compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if (__DEV__) {
return self;
}

var ReactVersion = "18.3.0-www-modern-d38eff48";
var ReactVersion = "18.3.0-www-modern-40562ec6";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -9904,7 +9904,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-modern-cb89a66b",
version: "18.3.0-www-modern-3c8129ec",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1302 = {
Expand Down Expand Up @@ -9935,7 +9935,7 @@ var internals$jscomp$inline_1302 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-cb89a66b"
reconcilerVersion: "18.3.0-www-modern-3c8129ec"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1303 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
40 changes: 28 additions & 12 deletions compiled/facebook-www/ReactDOMServer-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-classic-264fe41e";
var ReactVersion = "18.3.0-www-classic-af99950a";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -2114,9 +2114,6 @@ if (__DEV__) {
function createRenderState$1(
resumableState,
nonce,
bootstrapScriptContent,
bootstrapScripts,
bootstrapModules,
externalRuntimeConfig,
importMap,
onHeaders,
Expand All @@ -2131,6 +2128,9 @@ if (__DEV__) {
var idPrefix = resumableState.idPrefix;
var bootstrapChunks = [];
var externalRuntimeScript = null;
var bootstrapScriptContent = resumableState.bootstrapScriptContent,
bootstrapScripts = resumableState.bootstrapScripts,
bootstrapModules = resumableState.bootstrapModules;

if (bootstrapScriptContent !== undefined) {
bootstrapChunks.push(
Expand Down Expand Up @@ -2388,7 +2388,13 @@ if (__DEV__) {

return renderState;
}
function createResumableState(identifierPrefix, externalRuntimeConfig) {
function createResumableState(
identifierPrefix,
externalRuntimeConfig,
bootstrapScriptContent,
bootstrapScripts,
bootstrapModules
) {
var idPrefix = identifierPrefix === undefined ? "" : identifierPrefix;
var streamingFormat = ScriptStreamingFormat;

Expand All @@ -2402,6 +2408,9 @@ if (__DEV__) {
idPrefix: idPrefix,
nextFormID: 0,
streamingFormat: streamingFormat,
bootstrapScriptContent: bootstrapScriptContent,
bootstrapScripts: bootstrapScripts,
bootstrapModules: bootstrapModules,
instructions: NothingSent,
hasBody: false,
hasHtml: false,
Expand Down Expand Up @@ -5337,7 +5346,10 @@ if (__DEV__) {
target.push(endChunkForTag(type));
}

function writeBootstrap(destination, renderState) {
function writeBootstrap(destination, renderState, resumableState) {
resumableState.bootstrapScriptContent = undefined;
resumableState.bootstrapScripts = undefined;
resumableState.bootstrapModules = undefined;
var bootstrapChunks = renderState.bootstrapChunks;
var i = 0;

Expand All @@ -5354,8 +5366,8 @@ if (__DEV__) {
return true;
}

function writeCompletedRoot(destination, renderState) {
return writeBootstrap(destination, renderState);
function writeCompletedRoot(destination, renderState, resumableState) {
return writeBootstrap(destination, renderState, resumableState);
} // Structural Nodes
// A placeholder is a node inside a hidden partial tree that can be filled in later, but before
// display. It's never visible to users. We use the template tag because it can be used in every
Expand Down Expand Up @@ -5797,7 +5809,9 @@ if (__DEV__) {
writeMore = writeChunkAndReturn(destination, completeBoundaryDataEnd);
}

return writeBootstrap(destination, renderState) && writeMore;
return (
writeBootstrap(destination, renderState, resumableState) && writeMore
);
}
var clientRenderScript1Full = stringToPrecomputedChunk(
clientRenderBoundary + ';$RX("'
Expand Down Expand Up @@ -7785,8 +7799,6 @@ if (__DEV__) {
undefined,
undefined,
undefined,
undefined,
undefined,
undefined
);
return {
Expand Down Expand Up @@ -13946,7 +13958,11 @@ if (__DEV__) {

flushSegment(request, destination, completedRootSegment);
request.completedRootSegment = null;
writeCompletedRoot(destination, request.renderState);
writeCompletedRoot(
destination,
request.renderState,
request.resumableState
);
} else {
// We haven't flushed the root yet so we don't need to check any other branches further down
return;
Expand Down
40 changes: 28 additions & 12 deletions compiled/facebook-www/ReactDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-modern-d38eff48";
var ReactVersion = "18.3.0-www-modern-40562ec6";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -2114,9 +2114,6 @@ if (__DEV__) {
function createRenderState$1(
resumableState,
nonce,
bootstrapScriptContent,
bootstrapScripts,
bootstrapModules,
externalRuntimeConfig,
importMap,
onHeaders,
Expand All @@ -2131,6 +2128,9 @@ if (__DEV__) {
var idPrefix = resumableState.idPrefix;
var bootstrapChunks = [];
var externalRuntimeScript = null;
var bootstrapScriptContent = resumableState.bootstrapScriptContent,
bootstrapScripts = resumableState.bootstrapScripts,
bootstrapModules = resumableState.bootstrapModules;

if (bootstrapScriptContent !== undefined) {
bootstrapChunks.push(
Expand Down Expand Up @@ -2388,7 +2388,13 @@ if (__DEV__) {

return renderState;
}
function createResumableState(identifierPrefix, externalRuntimeConfig) {
function createResumableState(
identifierPrefix,
externalRuntimeConfig,
bootstrapScriptContent,
bootstrapScripts,
bootstrapModules
) {
var idPrefix = identifierPrefix === undefined ? "" : identifierPrefix;
var streamingFormat = ScriptStreamingFormat;

Expand All @@ -2402,6 +2408,9 @@ if (__DEV__) {
idPrefix: idPrefix,
nextFormID: 0,
streamingFormat: streamingFormat,
bootstrapScriptContent: bootstrapScriptContent,
bootstrapScripts: bootstrapScripts,
bootstrapModules: bootstrapModules,
instructions: NothingSent,
hasBody: false,
hasHtml: false,
Expand Down Expand Up @@ -5337,7 +5346,10 @@ if (__DEV__) {
target.push(endChunkForTag(type));
}

function writeBootstrap(destination, renderState) {
function writeBootstrap(destination, renderState, resumableState) {
resumableState.bootstrapScriptContent = undefined;
resumableState.bootstrapScripts = undefined;
resumableState.bootstrapModules = undefined;
var bootstrapChunks = renderState.bootstrapChunks;
var i = 0;

Expand All @@ -5354,8 +5366,8 @@ if (__DEV__) {
return true;
}

function writeCompletedRoot(destination, renderState) {
return writeBootstrap(destination, renderState);
function writeCompletedRoot(destination, renderState, resumableState) {
return writeBootstrap(destination, renderState, resumableState);
} // Structural Nodes
// A placeholder is a node inside a hidden partial tree that can be filled in later, but before
// display. It's never visible to users. We use the template tag because it can be used in every
Expand Down Expand Up @@ -5797,7 +5809,9 @@ if (__DEV__) {
writeMore = writeChunkAndReturn(destination, completeBoundaryDataEnd);
}

return writeBootstrap(destination, renderState) && writeMore;
return (
writeBootstrap(destination, renderState, resumableState) && writeMore
);
}
var clientRenderScript1Full = stringToPrecomputedChunk(
clientRenderBoundary + ';$RX("'
Expand Down Expand Up @@ -7785,8 +7799,6 @@ if (__DEV__) {
undefined,
undefined,
undefined,
undefined,
undefined,
undefined
);
return {
Expand Down Expand Up @@ -13674,7 +13686,11 @@ if (__DEV__) {

flushSegment(request, destination, completedRootSegment);
request.completedRootSegment = null;
writeCompletedRoot(destination, request.renderState);
writeCompletedRoot(
destination,
request.renderState,
request.resumableState
);
} else {
// We haven't flushed the root yet so we don't need to check any other branches further down
return;
Expand Down
Loading

0 comments on commit 6e10ef7

Please sign in to comment.