react
react copied to clipboard
[Flight] Implement FlightClient in terms of Thenable/Promises instead of throwing Promises
This moves the Flight Client's to use Chunks that mimick a variant of Promises instead of relying on throwing Promises. It still throws Promises in the bounds (readRoot and the generate React.lazy init) but that can be removed in a follow up.
There are a number of things that I'm not too happy about in this implementation:
The Webpack plugin isn't quite ideal. Not sure if that should even use the status fields.
There is a somewhat of an edge case where a model can reference a module that is still loading. Modules are the only external resource that we're blocked on. This then can turn other models to become blocked too. This was pretty simple but inefficient before. It would just throw and reparse the model every time something pinged. Which was fine because it's an edge case that you use it and even more so that the module isn't already resolved.
The Chunks extend Promise but they're not actually compatible because the the then()
doesn't return another Promise. Similarly, there's no way to lazy initialize without allocating and adding a listener at the same time even though it can synchronously resolve. If we have added listeners before, there's no way to ping and only if it's actually read then initialize it.
I'm also not sure if I'm over optimizing over being able to use the built-in Promises more.
It's just way more code.
Comparing: c91a1e03be54733a7dbfcb5663d7a9e8606ab1c1...1c481e9873fb5460b2fa050c78ddb2ef49dd6585
Critical size changes
Includes critical production bundles, as well as any change greater than 2%:
Significant size changes
Includes any change greater than 0.2%:
Expand to show
Generated by :no_entry_sign: dangerJS against 1c481e9873fb5460b2fa050c78ddb2ef49dd6585