mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add Relay Flight Build (#18242)
* Rename to clarify that it's client-only * Rename FizzStreamer to FizzServer for consistency * Rename react-flight to react-client/flight For consistency with react-server. Currently this just includes flight but it could be expanded to include the whole reconciler. * Add Relay Flight Build * Rename ReactServerHostConfig to ReactServerStreamConfig This will be the config specifically for streaming purposes. There will be other configs for other purposes.
This commit is contained in:
@@ -49,7 +49,7 @@ function writeConfig(renderer, rendererInfo, isServerSupported) {
|
||||
'%REACT_RENDERER_FLOW_OPTIONS%',
|
||||
`
|
||||
module.name_mapper='ReactFiberHostConfig$$' -> 'forks/ReactFiberHostConfig.${renderer}'
|
||||
module.name_mapper='ReactServerHostConfig$$' -> 'forks/ReactServerHostConfig.${serverRenderer}'
|
||||
module.name_mapper='ReactServerStreamConfig$$' -> 'forks/ReactServerStreamConfig.${serverRenderer}'
|
||||
module.name_mapper='ReactServerFormatConfig$$' -> 'forks/ReactServerFormatConfig.${serverRenderer}'
|
||||
module.name_mapper='ReactFlightClientHostConfig$$' -> 'forks/ReactFlightClientHostConfig.${serverRenderer}'
|
||||
`.trim(),
|
||||
|
||||
@@ -11,35 +11,35 @@ jest.mock('react-reconciler', () => {
|
||||
return require.requireActual('react-reconciler');
|
||||
};
|
||||
});
|
||||
const shimServerHostConfigPath = 'react-server/src/ReactServerHostConfig';
|
||||
const shimServerStreamConfigPath = 'react-server/src/ReactServerStreamConfig';
|
||||
const shimServerFormatConfigPath = 'react-server/src/ReactServerFormatConfig';
|
||||
jest.mock('react-server', () => {
|
||||
return config => {
|
||||
jest.mock(shimServerHostConfigPath, () => config);
|
||||
jest.mock(shimServerStreamConfigPath, () => config);
|
||||
jest.mock(shimServerFormatConfigPath, () => config);
|
||||
return require.requireActual('react-server');
|
||||
};
|
||||
});
|
||||
jest.mock('react-server/flight', () => {
|
||||
return config => {
|
||||
jest.mock(shimServerHostConfigPath, () => config);
|
||||
jest.mock(shimServerStreamConfigPath, () => config);
|
||||
jest.mock(shimServerFormatConfigPath, () => config);
|
||||
return require.requireActual('react-server/flight');
|
||||
};
|
||||
});
|
||||
const shimFlightClientHostConfigPath =
|
||||
'react-flight/src/ReactFlightClientHostConfig';
|
||||
jest.mock('react-flight', () => {
|
||||
'react-client/src/ReactFlightClientHostConfig';
|
||||
jest.mock('react-client/flight', () => {
|
||||
return config => {
|
||||
jest.mock(shimFlightClientHostConfigPath, () => config);
|
||||
return require.requireActual('react-flight');
|
||||
return require.requireActual('react-client/flight');
|
||||
};
|
||||
});
|
||||
|
||||
const configPaths = [
|
||||
'react-reconciler/src/ReactFiberHostConfig',
|
||||
'react-flight/src/ReactFlightClientHostConfig',
|
||||
'react-server/src/ReactServerHostConfig',
|
||||
'react-client/src/ReactFlightClientHostConfig',
|
||||
'react-server/src/ReactServerStreamConfig',
|
||||
'react-server/src/ReactServerFormatConfig',
|
||||
];
|
||||
|
||||
|
||||
@@ -197,6 +197,24 @@ const bundles = [
|
||||
externals: ['react'],
|
||||
},
|
||||
|
||||
/******* React DOM Flight Server Relay *******/
|
||||
{
|
||||
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD],
|
||||
moduleType: RENDERER,
|
||||
entry: 'react-flight-dom-relay/server',
|
||||
global: 'ReactFlightDOMRelayServer',
|
||||
externals: ['react', 'react-dom/server'],
|
||||
},
|
||||
|
||||
/******* React DOM Flight Client Relay *******/
|
||||
{
|
||||
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD],
|
||||
moduleType: RENDERER,
|
||||
entry: 'react-flight-dom-relay',
|
||||
global: 'ReactFlightDOMRelayClient',
|
||||
externals: ['react'],
|
||||
},
|
||||
|
||||
/******* React ART *******/
|
||||
{
|
||||
bundleTypes: [
|
||||
@@ -384,7 +402,7 @@ const bundles = [
|
||||
{
|
||||
bundleTypes: [NODE_DEV, NODE_PROD],
|
||||
moduleType: RECONCILER,
|
||||
entry: 'react-flight',
|
||||
entry: 'react-client/flight',
|
||||
global: 'ReactFlightClient',
|
||||
externals: ['react'],
|
||||
},
|
||||
|
||||
@@ -298,7 +298,7 @@ const forks = Object.freeze({
|
||||
);
|
||||
},
|
||||
|
||||
'react-server/src/ReactServerHostConfig': (
|
||||
'react-server/src/ReactServerStreamConfig': (
|
||||
bundleType,
|
||||
entry,
|
||||
dependencies,
|
||||
@@ -316,11 +316,11 @@ const forks = Object.freeze({
|
||||
if (!rendererInfo.isServerSupported) {
|
||||
return null;
|
||||
}
|
||||
return `react-server/src/forks/ReactServerHostConfig.${rendererInfo.shortName}.js`;
|
||||
return `react-server/src/forks/ReactServerStreamConfig.${rendererInfo.shortName}.js`;
|
||||
}
|
||||
}
|
||||
throw new Error(
|
||||
'Expected ReactServerHostConfig to always be replaced with a shim, but ' +
|
||||
'Expected ReactServerStreamConfig to always be replaced with a shim, but ' +
|
||||
`found no mention of "${entry}" entry point in ./scripts/shared/inlinedHostConfigs.js. ` +
|
||||
'Did you mean to add it there to associate it with a specific renderer?'
|
||||
);
|
||||
@@ -354,13 +354,13 @@ const forks = Object.freeze({
|
||||
);
|
||||
},
|
||||
|
||||
'react-flight/src/ReactFlightClientHostConfig': (
|
||||
'react-client/src/ReactFlightClientHostConfig': (
|
||||
bundleType,
|
||||
entry,
|
||||
dependencies,
|
||||
moduleType
|
||||
) => {
|
||||
if (dependencies.indexOf('react-flight') !== -1) {
|
||||
if (dependencies.indexOf('react-client') !== -1) {
|
||||
return null;
|
||||
}
|
||||
if (moduleType !== RENDERER && moduleType !== RECONCILER) {
|
||||
@@ -372,7 +372,7 @@ const forks = Object.freeze({
|
||||
if (!rendererInfo.isServerSupported) {
|
||||
return null;
|
||||
}
|
||||
return `react-flight/src/forks/ReactFlightClientHostConfig.${rendererInfo.shortName}.js`;
|
||||
return `react-client/src/forks/ReactFlightClientHostConfig.${rendererInfo.shortName}.js`;
|
||||
}
|
||||
}
|
||||
throw new Error(
|
||||
|
||||
@@ -78,11 +78,18 @@ module.exports = [
|
||||
isFlowTyped: true,
|
||||
isServerSupported: false,
|
||||
},
|
||||
{
|
||||
shortName: 'dom-relay',
|
||||
entryPoints: ['react-flight-dom-relay', 'react-flight-dom-relay/server'],
|
||||
paths: ['react-dom', 'react-flight-dom-relay'],
|
||||
isFlowTyped: true,
|
||||
isServerSupported: true,
|
||||
},
|
||||
{
|
||||
shortName: 'custom',
|
||||
entryPoints: [
|
||||
'react-reconciler',
|
||||
'react-flight',
|
||||
'react-client/flight',
|
||||
'react-server',
|
||||
'react-server/flight',
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user