-
Notifications
You must be signed in to change notification settings - Fork 49.6k
[Fizz] Add Node Web Streams bundle for SSR #33441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Comparing: 3705486...4735f9c Critical size changesIncludes critical production bundles, as well as any change greater than 2%: Significant size changesIncludes any change greater than 0.2%: Expand to show |
0655dbd to
393b2e9
Compare
393b2e9 to
4735f9c
Compare
| export type BinaryChunk = Uint8Array; | ||
|
|
||
| export function scheduleWork(callback: () => void) { | ||
| setImmediate(callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big one. The Edge build uses setTimeout which might not be as fast as setImmediate in Node but is in Edge environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:feels-good:
New take on #33441. This uses a wrapper instead of a separate bundle.
We highly recommend using Node Streams in Node.js because it's much faster and it is less likely to cause issues when chained in things like compression algorithms that need explicit flushing which the Web Streams ecosystem doesn't have a good solution for. However, that said, people want to be able to use the worse option for various reasons.
The
.edgebuilds aren't technically intended for Node.js. A Node.js environments needs to be patched in various ways to support it. It's also less optimal since it can't use Node.js exclusive features and have to use the lowest common denominator such as JS implementations instead of native.This adds a Web Streams build of Fizz but exclusively for Node.js so that in it we can rely on Node.js modules. The main difference compared to Edge is that SSR now uses
createHashfrom the"crypto"module and importsTextEncoderfrom"util". We usesetImmediateinstead ofsetTimeout.The public API is just
react-dom/serverwhich in Node.js automatically importsreact-dom/server.nodewhich re-exports the legacy bundle, Node Streams bundle and Node Web Streams bundle. The main downside is if your bundler isn't smart to DCE this barrel file.With Flight the difference is larger but that's a bigger lift.