-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR implements preloading of CSS from RSC. 1. The underlying Flight protocol was extended in facebook/react#26502 to allow sending hints from RSC to SSR and Client runtimes. React was updated to include these changes. 2. We now call `ReactDOM.preload()` for each stylesheet used in a layout/page layer There are a few implementation details to take note of 1. we were previously using the `.browser` variant of a few React packages. This was a holdover from when there was just browser and node and we wanted to use the browser variant b/c we wanted the same code to work in edge/node runtimes. React now publishes a `.edge` variant which is like `.browser` but expects to be server only. This is necessary to get the opt-in for `AsyncLocalStorage`. 2. Even with the above change, AsyncLocalStorage was not patched on the global scope until after React was loaded. I moved this into a module which is loaded first 3. The component passed to RSC's `renderToReadableStream` is not actually part of the RSC module graph. If I tried to call `ReactDOM.preload()` inside that function or any other function defined inside `app-render.tsx` file it would actually see the wrong instance of `react-dom`. I added a new export on the RSC top level export which exposes a `preloadStyle(...)` function which just delegates to `ReactDOM.preload(...)`. This makes the preload run in the right module graph ~There are a couple of bugs in React that this work uncovered that I will upstream. We may want to delay merging until they are addressed. I'll update this comment when that is complete.~ 1. ~React, during SSR, can emit a preload for a style twice in some circumstances because late discovered stylesheets don't consider whether a preload has already been flushed when preparing to reveal a boundary they are within~ 2. ~React, during RSC updates on the client, can preload a style that is already in the document because it currently only looks for existing preload links and does not consider if there is a stylesheet link with the same href.~ ~both of these issues will not break functionality, they just make the network tab look at bit more noisy. We would expect network deduping to prevent multiple actual loads~ The above React bugs were fixed and included now in the React update in this PR --------- Co-authored-by: Shu Ding <[email protected]>
- Loading branch information
Showing
88 changed files
with
13,028 additions
and
9,690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,13 +196,13 @@ | |
"random-seed": "0.3.0", | ||
"react": "18.2.0", | ||
"react-17": "npm:[email protected]", | ||
"react-builtin": "npm:[email protected]c8369527e-20230420", | ||
"react-experimental-builtin": "npm:[email protected]c8369527e-20230420", | ||
"react-builtin": "npm:[email protected]6eadbe0c4-20230425", | ||
"react-experimental-builtin": "npm:[email protected]6eadbe0c4-20230425", | ||
"react-dom": "18.2.0", | ||
"react-dom-17": "npm:[email protected]", | ||
"react-dom-builtin": "npm:[email protected]c8369527e-20230420", | ||
"react-dom-experimental-builtin": "npm:[email protected]c8369527e-20230420", | ||
"react-server-dom-webpack": "18.3.0-next-1f248bdd7-20230419", | ||
"react-dom-builtin": "npm:[email protected]6eadbe0c4-20230425", | ||
"react-dom-experimental-builtin": "npm:[email protected]6eadbe0c4-20230425", | ||
"react-server-dom-webpack": "18.3.0-next-6eadbe0c4-20230425", | ||
"react-ssr-prepass": "1.0.8", | ||
"react-virtualized": "9.22.3", | ||
"relay-compiler": "13.0.2", | ||
|
@@ -213,8 +213,8 @@ | |
"rimraf": "3.0.2", | ||
"sass": "1.54.0", | ||
"satori": "0.4.4", | ||
"scheduler-builtin": "npm:[email protected]c8369527e-20230420", | ||
"scheduler-experimental-builtin": "npm:[email protected]c8369527e-20230420", | ||
"scheduler-builtin": "npm:[email protected]6eadbe0c4-20230425", | ||
"scheduler-experimental-builtin": "npm:[email protected]6eadbe0c4-20230425", | ||
"seedrandom": "3.0.5", | ||
"selenium-webdriver": "4.0.0-beta.4", | ||
"semver": "7.3.7", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
267 changes: 182 additions & 85 deletions
267
...xt/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.development.js
Large diffs are not rendered by default.
Oops, something went wrong.
231 changes: 117 additions & 114 deletions
231
...src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.production.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
267 changes: 182 additions & 85 deletions
267
.../next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.node.development.js
Large diffs are not rendered by default.
Oops, something went wrong.
256 changes: 130 additions & 126 deletions
256
...xt/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.node.production.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.