dillon1000/react
Commit
Browse files [Fizz] Add Node Web Streams bundle for SSR (#33441)
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 `.edge` builds 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](https://github.com/facebook/react/pull/33388) and have to use [the lowest common denominator](https://github.com/facebook/react/pull/27399) 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 `createHash` from the `"crypto"` module and imports `TextEncoder` from `"util"`. We use `setImmediate` instead of `setTimeout`. The public API is just `react-dom/server` which in Node.js automatically imports `react-dom/server.node` which 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.
Changed paths13 files
First-parent comparisonpackages/react-dom/npm/server.node.js ModifiedM packages/react-dom/npm/static.node.js ModifiedM packages/react-dom/server.node.js ModifiedA packages/react-dom/src/__tests__/ReactDOMFizzServerNodeWebStreams-test.js AddedA packages/react-dom/src/__tests__/ReactDOMFizzStaticNodeWebStreams-test.js AddedA packages/react-dom/src/server/react-dom-server.node-webstreams.js AddedA packages/react-dom/src/server/react-dom-server.node-webstreams.stable.js AddedM packages/react-dom/static.node.js ModifiedA packages/react-server/src/ReactServerStreamConfigNodeWebStreams.js AddedA packages/react-server/src/forks/ReactServerStreamConfig.dom-node-webstreams.js AddedM packages/react/src/__tests__/ReactMismatchedVersions-test.js ModifiedM scripts/rollup/bundles.js ModifiedM scripts/shared/inlinedHostConfigs.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…