Skip to content

Commit

Permalink
[Float][Fizz] add crossOrigin support for preloading bootstrap script…
Browse files Browse the repository at this point in the history
…s and bootstrap modules (#26942)

The recently merged support for crossorigin in bootstrap scripts did not
implement the functionality for preloading. This adds it

see #26844

DiffTrain build for [a7bf5ba](a7bf5ba)
  • Loading branch information
gnoff committed Jun 13, 2023
1 parent 717bf32 commit 1d94a43
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
90229eb925e2330667fb7c023a5c4317c7ae8363
a7bf5ba614c6ddbd1eb3057c71f72efd1b6c21a9
16 changes: 9 additions & 7 deletions compiled/facebook-www/ReactDOMServer-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-classic-81c3ac25";
var ReactVersion = "18.3.0-www-classic-22ab72ab";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -2471,7 +2471,7 @@ function createResponseState$1(
: scriptConfig.crossOrigin === "use-credentials"
? "use-credentials"
: "";
preloadBootstrapScript(resources, src, nonce, integrity);
preloadBootstrapScript(resources, src, nonce, integrity, crossOrigin);
bootstrapChunks.push(
startScriptSrc,
stringToChunk(escapeTextForBrowser(src))
Expand Down Expand Up @@ -2519,7 +2519,7 @@ function createResponseState$1(
? "use-credentials"
: "";

preloadBootstrapModule(resources, _src, nonce, _integrity);
preloadBootstrapModule(resources, _src, nonce, _integrity, _crossOrigin);
bootstrapChunks.push(
startModuleSrc,
stringToChunk(escapeTextForBrowser(_src))
Expand Down Expand Up @@ -7424,7 +7424,7 @@ function preinit(href, options) {
// scripts at any other point in time we will need to check whether the preload
// already exists and not assume it

function preloadBootstrapScript(resources, src, nonce, integrity) {
function preloadBootstrapScript(resources, src, nonce, integrity, crossOrigin) {
var key = getResourceKey("script", src);

{
Expand All @@ -7444,7 +7444,8 @@ function preloadBootstrapScript(resources, src, nonce, integrity) {
href: src,
as: "script",
nonce: nonce,
integrity: integrity
integrity: integrity,
crossOrigin: crossOrigin
};
var resource = {
type: "preload",
Expand All @@ -7460,7 +7461,7 @@ function preloadBootstrapScript(resources, src, nonce, integrity) {
// scripts at any other point in time we will need to check whether the preload
// already exists and not assume it

function preloadBootstrapModule(resources, src, nonce, integrity) {
function preloadBootstrapModule(resources, src, nonce, integrity, crossOrigin) {
var key = getResourceKey("script", src);

{
Expand All @@ -7479,7 +7480,8 @@ function preloadBootstrapModule(resources, src, nonce, integrity) {
rel: "modulepreload",
href: src,
nonce: nonce,
integrity: integrity
integrity: integrity,
crossOrigin: crossOrigin
};
var resource = {
type: "preload",
Expand Down
16 changes: 9 additions & 7 deletions compiled/facebook-www/ReactDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-modern-bff42cc0";
var ReactVersion = "18.3.0-www-modern-27b3679a";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -2471,7 +2471,7 @@ function createResponseState$1(
: scriptConfig.crossOrigin === "use-credentials"
? "use-credentials"
: "";
preloadBootstrapScript(resources, src, nonce, integrity);
preloadBootstrapScript(resources, src, nonce, integrity, crossOrigin);
bootstrapChunks.push(
startScriptSrc,
stringToChunk(escapeTextForBrowser(src))
Expand Down Expand Up @@ -2519,7 +2519,7 @@ function createResponseState$1(
? "use-credentials"
: "";

preloadBootstrapModule(resources, _src, nonce, _integrity);
preloadBootstrapModule(resources, _src, nonce, _integrity, _crossOrigin);
bootstrapChunks.push(
startModuleSrc,
stringToChunk(escapeTextForBrowser(_src))
Expand Down Expand Up @@ -7424,7 +7424,7 @@ function preinit(href, options) {
// scripts at any other point in time we will need to check whether the preload
// already exists and not assume it

function preloadBootstrapScript(resources, src, nonce, integrity) {
function preloadBootstrapScript(resources, src, nonce, integrity, crossOrigin) {
var key = getResourceKey("script", src);

{
Expand All @@ -7444,7 +7444,8 @@ function preloadBootstrapScript(resources, src, nonce, integrity) {
href: src,
as: "script",
nonce: nonce,
integrity: integrity
integrity: integrity,
crossOrigin: crossOrigin
};
var resource = {
type: "preload",
Expand All @@ -7460,7 +7461,7 @@ function preloadBootstrapScript(resources, src, nonce, integrity) {
// scripts at any other point in time we will need to check whether the preload
// already exists and not assume it

function preloadBootstrapModule(resources, src, nonce, integrity) {
function preloadBootstrapModule(resources, src, nonce, integrity, crossOrigin) {
var key = getResourceKey("script", src);

{
Expand All @@ -7479,7 +7480,8 @@ function preloadBootstrapModule(resources, src, nonce, integrity) {
rel: "modulepreload",
href: src,
nonce: nonce,
integrity: integrity
integrity: integrity,
crossOrigin: crossOrigin
};
var resource = {
type: "preload",
Expand Down
14 changes: 8 additions & 6 deletions compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ function createResponseState(
: scriptConfig.crossOrigin === "use-credentials"
? "use-credentials"
: "";
preloadBootstrapScript(resources, src, nonce, integrity);
preloadBootstrapScript(resources, src, nonce, integrity, crossOrigin);
bootstrapChunks.push(
startScriptSrc,
stringToChunk(escapeTextForBrowser(src))
Expand Down Expand Up @@ -2516,7 +2516,7 @@ function createResponseState(
? "use-credentials"
: "";

preloadBootstrapModule(resources, _src, nonce, _integrity);
preloadBootstrapModule(resources, _src, nonce, _integrity, _crossOrigin);
bootstrapChunks.push(
startModuleSrc,
stringToChunk(escapeTextForBrowser(_src))
Expand Down Expand Up @@ -7431,7 +7431,7 @@ function preinit(href, options) {
// scripts at any other point in time we will need to check whether the preload
// already exists and not assume it

function preloadBootstrapScript(resources, src, nonce, integrity) {
function preloadBootstrapScript(resources, src, nonce, integrity, crossOrigin) {
var key = getResourceKey("script", src);

{
Expand All @@ -7451,7 +7451,8 @@ function preloadBootstrapScript(resources, src, nonce, integrity) {
href: src,
as: "script",
nonce: nonce,
integrity: integrity
integrity: integrity,
crossOrigin: crossOrigin
};
var resource = {
type: "preload",
Expand All @@ -7467,7 +7468,7 @@ function preloadBootstrapScript(resources, src, nonce, integrity) {
// scripts at any other point in time we will need to check whether the preload
// already exists and not assume it

function preloadBootstrapModule(resources, src, nonce, integrity) {
function preloadBootstrapModule(resources, src, nonce, integrity, crossOrigin) {
var key = getResourceKey("script", src);

{
Expand All @@ -7486,7 +7487,8 @@ function preloadBootstrapModule(resources, src, nonce, integrity) {
rel: "modulepreload",
href: src,
nonce: nonce,
integrity: integrity
integrity: integrity,
crossOrigin: crossOrigin
};
var resource = {
type: "preload",
Expand Down
6 changes: 4 additions & 2 deletions compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -3871,7 +3871,8 @@ exports.renderToStream = function (children, options) {
href: externalRuntimeConfig,
as: "script",
nonce: void 0,
integrity: integrity
integrity: integrity,
crossOrigin: scriptConfig
},
resource = { type: "preload", chunks: [], state: 0, props: props };
resources.preloadsMap.set("[script]" + externalRuntimeConfig, resource);
Expand Down Expand Up @@ -3914,7 +3915,8 @@ exports.renderToStream = function (children, options) {
rel: "modulepreload",
href: bootstrapScriptContent,
nonce: void 0,
integrity: externalRuntimeConfig
integrity: externalRuntimeConfig,
crossOrigin: integrity
}),
(props = {
type: "preload",
Expand Down

0 comments on commit 1d94a43

Please sign in to comment.