react/packages/react-server-dom-webpack
Sebastian Markbåge f172fa7461
[Flight] Detriplicate Objects (#27537)
Now that we no longer support Server Context, we can now deduplicate
objects. It's not completely safe for useId but only in the same way as
it's not safe if you reuse elements on the client, so it's not a new
issue.

This also solves cyclic object references.

The issue is that we prefer to inline objects into a plain JSON format
when an object is not going to get reused. In this case the object
doesn't have an id. We could potentially serialize a reference to an
existing model + a path to it but it bloats the format and complicates
the client.

In a smarter flush phase like we have in Fizz we could choose to inline
or outline depending on what we've discovered so far before a flush. We
can't do that here since we use native stringify. However, even in that
solution you might not know that you're going to discover the same
object later so it's not perfect deduping anyway.

Instead, I use a heuristic where I mark previously seen objects and if I
ever see that object again, then I'll outline it. The idea is that most
objects are just going to be emitted once and if it's more than once
it's fairly likely you have a shared reference to it somewhere and it
might be more than two.

The third object gets deduplicated (or "detriplicated").

It's not a perfect heuristic because when we write the second object we
will have already visited all the nested objects inside of it, which
causes us to outline every nested object too even those weren't
reference more than by that parent. Not sure how to solve for that.

If we for some other reason outline an object such as if it suspends,
then it's truly deduplicated since it already has an id.
2023-10-19 13:41:16 -04:00
..
esm Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
npm Create a bunch of custom webpack vs unbundled node bundles (#26172) 2023-02-16 11:01:52 -05:00
src [Flight] Detriplicate Objects (#27537) 2023-10-19 13:41:16 -04:00
client.browser.js Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
client.edge.js Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
client.js Create a bunch of custom webpack vs unbundled node bundles (#26172) 2023-02-16 11:01:52 -05:00
client.node.js Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
client.node.unbundled.js Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
index.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
node-register.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
package.json When selecting a package variant from an export map we should favor n… (#27030) 2023-07-06 10:50:59 -07:00
plugin.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
README.md [Flight] Rename react-transport-... packages to react-server-... (#20403) 2020-12-08 08:08:57 -05:00
server.browser.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
server.edge.js Add Edge Server Builds for workerd / edge-light (#26116) 2023-02-07 15:10:01 -05:00
server.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
server.node.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
server.node.unbundled.js Create a bunch of custom webpack vs unbundled node bundles (#26172) 2023-02-16 11:01:52 -05:00

react-server-dom-webpack

Experimental React Flight bindings for DOM using Webpack.

Use it at your own risk.