Skip to content

Commit

Permalink
Implements wiring for Flight to have it's own "HostConfig" separate f…
Browse files Browse the repository at this point in the history
…rom 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
  • Loading branch information
gnoff committed Apr 7, 2023
1 parent 657698e commit 2ee8c21
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
export * from 'react-client/src/ReactFlightClientHostConfigBrowser';
export * from 'react-client/src/ReactFlightClientHostConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig';
export * from 'react-dom-bindings/src/shared/ReactDOMFlightClientHostConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

export * from 'react-client/src/ReactFlightClientHostConfigBrowser';
export * from 'react-client/src/ReactFlightClientHostConfigStream';
export * from 'react-dom-bindings/src/shared/ReactDOMFlightClientHostConfig';

export type Response = any;
export opaque type SSRManifest = mixed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
export * from 'react-client/src/ReactFlightClientHostConfigBrowser';
export * from 'react-client/src/ReactFlightClientHostConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig';
export * from 'react-dom-bindings/src/shared/ReactDOMFlightClientHostConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
export * from 'react-client/src/ReactFlightClientHostConfigBrowser';
export * from 'react-client/src/ReactFlightClientHostConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig';
export * from 'react-dom-bindings/src/shared/ReactDOMFlightClientHostConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
export * from 'react-client/src/ReactFlightClientHostConfigNode';
export * from 'react-client/src/ReactFlightClientHostConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig';
export * from 'react-dom-bindings/src/shared/ReactDOMFlightClientHostConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
export * from 'react-client/src/ReactFlightClientHostConfigNode';
export * from 'react-client/src/ReactFlightClientHostConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightClientNodeBundlerConfig';
export * from 'react-dom-bindings/src/shared/ReactDOMFlightClientHostConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from 'react-server-dom-relay/src/ReactFlightDOMRelayClientHostConfig';
export * from '../ReactFlightClientHostConfigNoStream';
export * from 'react-dom-bindings/src/shared/ReactDOMFlightClientHostConfig';
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

// Used to distinguish these contexts from ones used in other renderers.
// E.g. this can be used to distinguish legacy renderers from this modern one.
export const isPrimaryRenderer = true;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

// This client file is in the shared folder because it applies to both SSR and browser contexts.
// It is the configuraiton of the FlightClient behavior which can run in either environment.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export const isPrimaryRenderer = true;

export function prepareHostDispatcher() {}
2 changes: 1 addition & 1 deletion packages/react-server/src/ReactFlightNewContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
} from 'shared/ReactTypes';

import {REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED} from 'shared/ReactSymbols';
import {isPrimaryRenderer} from './ReactServerFormatConfig';
import {isPrimaryRenderer} from './ReactFlightServerConfig';

let rendererSigil;
if (__DEV__) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

export * from '../ReactFlightServerConfigStream';
export * from '../ReactFlightServerBundlerConfigCustom';

export const isPrimaryRenderer = false;
export function prepareHostDispatcher() {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from '../ReactFlightServerConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig';
export * from 'react-dom-bindings/src/server/ReactDOMFlightServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from '../ReactFlightServerConfigStream';
export * from '../ReactFlightServerBundlerConfigCustom';
export * from 'react-dom-bindings/src/server/ReactDOMFlightServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from '../ReactFlightServerConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig';
export * from 'react-dom-bindings/src/server/ReactDOMFlightServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from '../ReactFlightServerConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig';
export * from 'react-dom-bindings/src/server/ReactDOMFlightServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from '../ReactFlightServerConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig';
export * from 'react-dom-bindings/src/server/ReactDOMFlightServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from '../ReactFlightServerConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig';
export * from 'react-dom-bindings/src/server/ReactDOMFlightServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*/

export * from 'react-server-dom-relay/src/ReactFlightDOMRelayServerHostConfig';
export * from 'react-dom-bindings/src/server/ReactDOMFlightServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*/

export * from 'react-server-native-relay/src/ReactFlightNativeRelayServerHostConfig';
export * from 'react-native-renderer/src/server/ReactNativeFlightServerFormatConfig';

0 comments on commit 2ee8c21

Please sign in to comment.