Commit f82e23e
committed
[Flight] Deduplicate chunk entries in client reference metadata
Each client reference in the RSC stream includes an array of chunk
entries (URLs or chunk ID/filename pairs) that the client needs to load.
When many client components share the same chunks, these strings were
repeated across every import row, significantly bloating the payload.
This change deduplicates individual chunk entries across client
references by outlining each unique entry as its own model row and
replacing it with a `$` reference in the import metadata. The client's
existing `parseModel` reviver resolves these references transparently,
so no client-side changes are needed.
Only string entries longer than 5 characters are outlined. Short strings
like webpack chunk IDs are kept inline since the `$` reference would be
close to the same size. If SRI (Subresource Integrity) support is added
in the future, the dedup strategy for chunk entries will need to be
revisited.
The debug and production streams use separate dedup maps
(`writtenDebugClientReferenceChunkEntries` and
`writtenClientReferenceChunkEntries`) because chunk model rows must
appear in the same stream as the import row that references them.1 parent af24e98 commit f82e23e
1 file changed
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
580 | 580 | | |
581 | 581 | | |
582 | 582 | | |
| 583 | + | |
583 | 584 | | |
584 | 585 | | |
585 | 586 | | |
| |||
604 | 605 | | |
605 | 606 | | |
606 | 607 | | |
| 608 | + | |
607 | 609 | | |
608 | 610 | | |
609 | 611 | | |
| |||
699 | 701 | | |
700 | 702 | | |
701 | 703 | | |
| 704 | + | |
702 | 705 | | |
703 | 706 | | |
704 | 707 | | |
| |||
724 | 727 | | |
725 | 728 | | |
726 | 729 | | |
| 730 | + | |
727 | 731 | | |
728 | 732 | | |
729 | 733 | | |
| |||
4326 | 4330 | | |
4327 | 4331 | | |
4328 | 4332 | | |
| 4333 | + | |
| 4334 | + | |
| 4335 | + | |
| 4336 | + | |
| 4337 | + | |
| 4338 | + | |
| 4339 | + | |
| 4340 | + | |
| 4341 | + | |
| 4342 | + | |
| 4343 | + | |
| 4344 | + | |
| 4345 | + | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
| 4349 | + | |
| 4350 | + | |
| 4351 | + | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
| 4355 | + | |
| 4356 | + | |
| 4357 | + | |
| 4358 | + | |
| 4359 | + | |
| 4360 | + | |
| 4361 | + | |
| 4362 | + | |
| 4363 | + | |
| 4364 | + | |
| 4365 | + | |
| 4366 | + | |
| 4367 | + | |
| 4368 | + | |
| 4369 | + | |
| 4370 | + | |
| 4371 | + | |
| 4372 | + | |
| 4373 | + | |
| 4374 | + | |
| 4375 | + | |
| 4376 | + | |
| 4377 | + | |
| 4378 | + | |
| 4379 | + | |
| 4380 | + | |
| 4381 | + | |
| 4382 | + | |
| 4383 | + | |
| 4384 | + | |
| 4385 | + | |
| 4386 | + | |
| 4387 | + | |
| 4388 | + | |
4329 | 4389 | | |
4330 | 4390 | | |
4331 | 4391 | | |
| |||
0 commit comments