@samitouri / QOS-React-2 / commits / f4f873f628

Implements wiring for Flight to have it's own "HostConfig" (#26590)

Part of https://github.com/facebook/react/pull/26571 Implements wiring for Flight to have it's own "HostConfig" from Fizz. Historically the ServerFormatConfigs were supposed to be generic enough to be used by Fizz and Flight. However with the addition of features like Float the configs have evolved to be more specific to the renderer. We may want to get back to a place where there is a pure FormatConfig which can be shared but for now we are embracing the fact that these runtimes need very different things and DCE cannot adequately remove the unused stuff for Fizz when pulling this dep into Flight so we are going to fork the configs and just maintain separate ones. At first the Flight config will be almost empty but once Float support in Flight lands it will have a more complex implementation Additionally this commit normalizes the component files which make up FlightServerConfig and FlightClientConfig. Now each file that participates starts with ReactFlightServerConfig... and ReactFlightClientConfig...

Josh Story committed Apr 10, 2023 at 14:51 UTC f4f873f6282e6f2e584990c00fb2aae86db85a8b
17 files changed +40 -1
packages/react-client/src/forks/ReactFlightClientConfig.dom-browser.js
+1
@@ -10,3 +10,4 @@
10 export * from 'react-client/src/ReactFlightClientConfigBrowser';
11 export * from 'react-client/src/ReactFlightClientConfigStream';
12 export * from 'react-server-dom-webpack/src/ReactFlightClientConfigWebpackBundler';
13 +export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js
+1
@@ -9,6 +9,7 @@
9
10 export * from 'react-client/src/ReactFlightClientConfigBrowser';
11 export * from 'react-client/src/ReactFlightClientConfigStream';
12 +export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
13
14 export type Response = any;
15 export opaque type SSRManifest = mixed;
packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-webpack.js
+1
@@ -10,3 +10,4 @@
10 export * from 'react-client/src/ReactFlightClientConfigBrowser';
11 export * from 'react-client/src/ReactFlightClientConfigStream';
12 export * from 'react-server-dom-webpack/src/ReactFlightClientConfigWebpackBundler';
13 +export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js
+1
@@ -10,3 +10,4 @@
10 export * from 'react-client/src/ReactFlightClientConfigBrowser';
11 export * from 'react-client/src/ReactFlightClientConfigStream';
12 export * from 'react-server-dom-webpack/src/ReactFlightClientConfigWebpackBundler';
13 +export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
packages/react-client/src/forks/ReactFlightClientConfig.dom-node-webpack.js
+1
@@ -10,3 +10,4 @@
10 export * from 'react-client/src/ReactFlightClientConfigNode';
11 export * from 'react-client/src/ReactFlightClientConfigStream';
12 export * from 'react-server-dom-webpack/src/ReactFlightClientConfigWebpackBundler';
13 +export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
packages/react-client/src/forks/ReactFlightClientConfig.dom-node.js
+1
@@ -10,3 +10,4 @@
10 export * from 'react-client/src/ReactFlightClientConfigNode';
11 export * from 'react-client/src/ReactFlightClientConfigStream';
12 export * from 'react-server-dom-webpack/src/ReactFlightClientConfigNodeBundler';
13 +export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
packages/react-client/src/forks/ReactFlightClientConfig.dom-relay.js
+1
@@ -9,3 +9,4 @@
9
10 export * from 'react-server-dom-relay/src/ReactFlightClientConfigDOMRelay';
11 export * from '../ReactFlightClientConfigNoStream';
12 +export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
packages/react-dom-bindings/src/server/ReactFlightServerConfigDOM.js new
+12
@@ -0,0 +1,12 @@
1 +/**
2 + * Copyright (c) Meta Platforms, Inc. and affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +// Used to distinguish these contexts from ones used in other renderers.
11 +// E.g. this can be used to distinguish legacy renderers from this modern one.
12 +export const isPrimaryRenderer = true;
packages/react-dom-bindings/src/shared/ReactFlightClientConfigDOM.js new
+13
@@ -0,0 +1,13 @@
1 +/**
2 + * Copyright (c) Meta Platforms, Inc. and affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +// This client file is in the shared folder because it applies to both SSR and browser contexts.
11 +// It is the configuraiton of the FlightClient behavior which can run in either environment.
12 +
13 +// In a future update this is where we will implement `dispatchDirective` such as for Float methods
packages/react-server/src/ReactFlightNewContext.js
+1 -1
@@ -13,7 +13,7 @@ import type {
13 } from 'shared/ReactTypes';
14
15 import {REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED} from 'shared/ReactSymbols';
16 -import {isPrimaryRenderer} from './ReactServerFormatConfig';
16 +import {isPrimaryRenderer} from './ReactFlightServerConfig';
17
18 let rendererSigil;
19 if (__DEV__) {
packages/react-server/src/forks/ReactFlightServerConfig.dom-browser.js
+1
@@ -9,3 +9,4 @@
9
10 export * from '../ReactFlightServerConfigStream';
11 export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler';
12 +export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
packages/react-server/src/forks/ReactFlightServerConfig.dom-bun.js
+1
@@ -9,3 +9,4 @@
9
10 export * from '../ReactFlightServerConfigStream';
11 export * from '../ReactFlightServerConfigBundlerCustom';
12 +export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-webpack.js
+1
@@ -9,3 +9,4 @@
9
10 export * from '../ReactFlightServerConfigStream';
11 export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler';
12 +export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
packages/react-server/src/forks/ReactFlightServerConfig.dom-legacy.js
+1
@@ -9,3 +9,4 @@
9
10 export * from '../ReactFlightServerConfigStream';
11 export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler';
12 +export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
packages/react-server/src/forks/ReactFlightServerConfig.dom-node-webpack.js
+1
@@ -9,3 +9,4 @@
9
10 export * from '../ReactFlightServerConfigStream';
11 export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler';
12 +export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js
+1
@@ -9,3 +9,4 @@
9
10 export * from '../ReactFlightServerConfigStream';
11 export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler';
12 +export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
packages/react-server/src/forks/ReactFlightServerConfig.dom-relay.js
+1
@@ -8,3 +8,4 @@
8 */
9
10 export * from 'react-server-dom-relay/src/ReactFlightServerConfigDOMRelay';
11 +export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';