From 4d7a7bc988fb258882ae01be9b9be84d42cfe576 Mon Sep 17 00:00:00 2001 From: Josh Story Date: Mon, 1 May 2023 09:21:24 -0700 Subject: [PATCH] Optimizing the way external fizz runtime is instantiated so we don't have to carry the nonce around on ResponseState --- .../src/server/ReactFizzConfigDOM.js | 58 ++++++++++--------- .../src/server/ReactFizzConfigDOMLegacy.js | 7 +-- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js index f4fae4d307efb..eed73b095f0a7 100644 --- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js +++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js @@ -130,11 +130,8 @@ export type ResponseState = { startInlineScript: PrecomputedChunk, instructions: InstructionState, - // state for outputting CSP nonce - nonce: string | void, - // state for data streaming format - externalRuntimeConfig: BootstrapScriptDescriptor | null, + externalRuntimeScript: null | ExternalRuntimeScript, // preamble and postamble chunks and state htmlChunks: null | Array, @@ -196,6 +193,10 @@ export type BootstrapScriptDescriptor = { src: string, integrity?: string, }; +export type ExternalRuntimeScript = { + src: string, + chunks: Array, +}; // Allows us to keep track of what we've already written so we can refer back to it. // if passed externalRuntimeConfig and the enableFizzExternalRuntime feature flag // is set, the server will send instructions via data attributes (instead of inline scripts) @@ -215,7 +216,7 @@ export function createResponseState( '