Commit 09b0ca4
authored
App Router - preinitialize chunks during SSR (#54752)
Today when we hydrate an SSR'd RSC response on the client we encounter import chunks which initiate code loading for client components. However we only start fetching these chunks after hydration has begun which is necessarily after the initial chunks for the entrypoint have loaded.
React has upstream changes that need to land which will preinitialize the rendered chunks for all client components used during the SSR pass. This will cause a `<script async="" src... />` tag to be emitted in the head for each chunk we need to load during hydration which allows the browser to start fetching these resources even before the entrypoint has started to execute.
Additionally the implementation for webpack and turbopack is different enough that there will be a new `react-server-dom-turbopack` package in the React repo which should be used when using Turbopack with Next.
This PR also removes a number of patches to React src that proxy loading (`__next_chunk_load__`) and bundler requires (`__next_require__`) through the `globalThis` object. Now the react packages can be fully responsible for implementing chunk loading and all Next needs to do is supply the necessary information such as chunk prefix and crossOrigin attributes necessary for this loading. This information is produced as part of the client-manifest by either a Webpack plugin or Turbopack.
Additionally any modifications to the chunk filename that were previously done at runtime need to be made in the manifest itself now. This means we need to encode the deployment id for skew protection and encode the filename to make it match our static path matching (and resolutions on s3) when using `[` and `]` segment characters.
There are a few followup items to consider in later PRs
1. we currently bundle a node and edge version of react-server-dom-webpack/client. The node version has an implementation for busboy whereas the edge version does not. Next is currently configured to use busboy when handling a fetch action sent as multipart with a node runtime. Ideally we'd only bundle the one platform we are buliding for but some additional refactoring to support better forking is possibly required here
This PR also updates react from 09285d5a7 to d900fadbf.
### React upstream changes
- facebook/react#27439
- facebook/react#26763
- facebook/react#27434
- facebook/react#27433
- facebook/react#27424
- facebook/react#27428
- facebook/react#27427
- facebook/react#27315
- facebook/react#27314
- facebook/react#27400
- facebook/react#27421
- facebook/react#27419
- facebook/react#274181 parent e34fdf2 commit 09b0ca4
File tree
192 files changed
+60997
-8647
lines changed- packages
- next-swc/crates
- next-api/src
- next-build/src
- next_app
- next-core/src
- next_manifests
- next
- src
- build
- webpack/plugins
- client
- components/react-dev-overlay/internal/helpers
- compiled
- react-dom-experimental
- cjs
- react-dom
- cjs
- react-experimental/cjs
- react-server-dom-turbopack-experimental
- cjs
- react-server-dom-turbopack
- cjs
- react-server-dom-webpack-experimental
- cjs
- react-server-dom-webpack
- cjs
- react/cjs
- server
- app-render
- future/route-modules/app-page/vendored
- rsc
- ssr
- types
- test
- e2e/app-dir
- app
- chunk-loading
- app
- _components/junk-drawer
- account
- feed
- components
- pages/page
- production/app-dir/subresource-integrity
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
192 files changed
+60997
-8647
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
203 | 205 | | |
204 | 206 | | |
205 | 207 | | |
| |||
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
212 | | - | |
213 | | - | |
| 214 | + | |
| 215 | + | |
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| |||
636 | 637 | | |
637 | 638 | | |
638 | 639 | | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
639 | 644 | | |
640 | 645 | | |
641 | 646 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
| |||
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
| 344 | + | |
343 | 345 | | |
344 | 346 | | |
345 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
| |||
Lines changed: 40 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
92 | 100 | | |
93 | 101 | | |
94 | 102 | | |
| |||
107 | 115 | | |
108 | 116 | | |
109 | 117 | | |
110 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
111 | 122 | | |
112 | 123 | | |
113 | 124 | | |
| |||
238 | 249 | | |
239 | 250 | | |
240 | 251 | | |
241 | | - | |
242 | 252 | | |
243 | 253 | | |
244 | 254 | | |
| |||
253 | 263 | | |
254 | 264 | | |
255 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
256 | 270 | | |
257 | 271 | | |
258 | 272 | | |
| |||
487 | 501 | | |
488 | 502 | | |
489 | 503 | | |
490 | | - | |
| 504 | + | |
491 | 505 | | |
| 506 | + | |
| 507 | + | |
492 | 508 | | |
493 | 509 | | |
494 | | - | |
| 510 | + | |
495 | 511 | | |
496 | 512 | | |
497 | 513 | | |
| |||
505 | 521 | | |
506 | 522 | | |
507 | 523 | | |
508 | | - | |
| 524 | + | |
509 | 525 | | |
| 526 | + | |
| 527 | + | |
510 | 528 | | |
511 | 529 | | |
512 | | - | |
| 530 | + | |
513 | 531 | | |
514 | 532 | | |
515 | 533 | | |
| |||
580 | 598 | | |
581 | 599 | | |
582 | 600 | | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
583 | 609 | | |
584 | 610 | | |
585 | 611 | | |
| |||
610 | 636 | | |
611 | 637 | | |
612 | 638 | | |
613 | | - | |
| 639 | + | |
614 | 640 | | |
| 641 | + | |
| 642 | + | |
615 | 643 | | |
616 | 644 | | |
617 | | - | |
| 645 | + | |
618 | 646 | | |
619 | 647 | | |
620 | 648 | | |
| |||
625 | 653 | | |
626 | 654 | | |
627 | 655 | | |
628 | | - | |
| 656 | + | |
629 | 657 | | |
| 658 | + | |
| 659 | + | |
630 | 660 | | |
631 | 661 | | |
632 | | - | |
| 662 | + | |
633 | 663 | | |
634 | 664 | | |
635 | 665 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| |||
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
195 | 203 | | |
196 | 204 | | |
197 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments