Skip to content

Commit 39a7730

Browse files
authored
Rename SSRManifest to ServerConsumerManifest (#31299)
This config is more generally applicable to all server-side Flight Clients and not just SSR.
1 parent 1839e14 commit 39a7730

20 files changed

+106
-100
lines changed

fixtures/flight/server/global.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async function renderApp(req, res, next) {
130130
buildPath = path.join(__dirname, '../build/');
131131
}
132132
// Read the module map from the virtual file system.
133-
const ssrManifest = JSON.parse(
133+
const serverConsumerManifest = JSON.parse(
134134
await virtualFs.readFile(
135135
path.join(buildPath, 'react-ssr-manifest.json'),
136136
'utf8'
@@ -160,14 +160,20 @@ async function renderApp(req, res, next) {
160160
rscResponse.pipe(rscResponse1);
161161
rscResponse.pipe(rscResponse2);
162162

163-
const {formState} = await createFromNodeStream(rscResponse1, ssrManifest);
163+
const {formState} = await createFromNodeStream(
164+
rscResponse1,
165+
serverConsumerManifest
166+
);
164167
rscResponse1.end();
165168

166169
let cachedResult;
167170
let Root = () => {
168171
if (!cachedResult) {
169172
// Read this stream inside the render.
170-
cachedResult = createFromNodeStream(rscResponse2, ssrManifest);
173+
cachedResult = createFromNodeStream(
174+
rscResponse2,
175+
serverConsumerManifest
176+
);
171177
}
172178
return React.use(cachedResult).root;
173179
};

packages/react-client/src/ReactFlightClient.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {LazyComponent} from 'react/src/ReactLazy';
2020
import type {
2121
ClientReference,
2222
ClientReferenceMetadata,
23-
SSRModuleMap,
23+
ServerConsumerModuleMap,
2424
StringDecoder,
2525
ModuleLoading,
2626
} from './ReactFlightClientConfig';
@@ -269,7 +269,7 @@ export type FindSourceMapURLCallback = (
269269
) => null | string;
270270

271271
export type Response = {
272-
_bundlerConfig: SSRModuleMap,
272+
_bundlerConfig: ServerConsumerModuleMap,
273273
_moduleLoading: ModuleLoading,
274274
_callServer: CallServerCallback,
275275
_encodeFormAction: void | EncodeFormActionCallback,
@@ -1420,7 +1420,7 @@ function missingCall() {
14201420

14211421
function ResponseInstance(
14221422
this: $FlowFixMe,
1423-
bundlerConfig: SSRModuleMap,
1423+
bundlerConfig: ServerConsumerModuleMap,
14241424
moduleLoading: ModuleLoading,
14251425
callServer: void | CallServerCallback,
14261426
encodeFormAction: void | EncodeFormActionCallback,
@@ -1485,7 +1485,7 @@ function ResponseInstance(
14851485
}
14861486

14871487
export function createResponse(
1488-
bundlerConfig: SSRModuleMap,
1488+
bundlerConfig: ServerConsumerModuleMap,
14891489
moduleLoading: ModuleLoading,
14901490
callServer: void | CallServerCallback,
14911491
encodeFormAction: void | EncodeFormActionCallback,

packages/react-client/src/forks/ReactFlightClientConfig.custom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
declare const $$$config: any;
2727

2828
export opaque type ModuleLoading = mixed;
29-
export opaque type SSRModuleMap = mixed;
29+
export opaque type ServerConsumerModuleMap = mixed;
3030
export opaque type ServerManifest = mixed;
3131
export opaque type ServerReferenceId = string;
3232
export opaque type ClientReferenceMetadata = mixed;

packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export * from 'react-client/src/ReactClientConsoleConfigPlain';
1515
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
1616

1717
export opaque type ModuleLoading = mixed;
18-
export opaque type SSRModuleMap = mixed;
18+
export opaque type ServerConsumerModuleMap = mixed;
1919
export opaque type ServerManifest = mixed;
2020
export opaque type ServerReferenceId = string;
2121
export opaque type ClientReferenceMetadata = mixed;

packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export * from 'react-client/src/ReactClientConsoleConfigBrowser';
1515

1616
export type Response = any;
1717
export opaque type ModuleLoading = mixed;
18-
export opaque type SSRModuleMap = mixed;
18+
export opaque type ServerConsumerModuleMap = mixed;
1919
export opaque type ServerManifest = mixed;
2020
export opaque type ServerReferenceId = string;
2121
export opaque type ClientReferenceMetadata = mixed;

packages/react-client/src/forks/ReactFlightClientConfig.markup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export * from 'react-markup/src/ReactMarkupLegacyClientStreamConfig.js';
1616
export * from 'react-client/src/ReactClientConsoleConfigPlain';
1717

1818
export type ModuleLoading = null;
19-
export type SSRModuleMap = null;
19+
export type ServerConsumerModuleMap = null;
2020
export opaque type ServerManifest = null;
2121
export opaque type ServerReferenceId = string;
2222
export opaque type ClientReferenceMetadata = null;
@@ -33,7 +33,7 @@ export function prepareDestinationForModule(
3333
}
3434

3535
export function resolveClientReference<T>(
36-
bundlerConfig: SSRModuleMap,
36+
bundlerConfig: ServerConsumerModuleMap,
3737
metadata: ClientReferenceMetadata,
3838
): ClientReference<T> {
3939
throw new Error(

packages/react-server-dom-esm/src/client/ReactFlightClientConfigBundlerESM.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
} from 'shared/ReactTypes';
1515
import type {ModuleLoading} from 'react-client/src/ReactFlightClientConfig';
1616

17-
export type SSRModuleMap = string; // Module root path
17+
export type ServerConsumerModuleMap = string; // Module root path
1818

1919
export type ServerManifest = string; // Module root path
2020

@@ -48,7 +48,7 @@ export function prepareDestinationForModule(
4848
}
4949

5050
export function resolveClientReference<T>(
51-
bundlerConfig: SSRModuleMap,
51+
bundlerConfig: ServerConsumerModuleMap,
5252
metadata: ClientReferenceMetadata,
5353
): ClientReference<T> {
5454
const baseURL = bundlerConfig;

packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMEdge-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe('ReactFlightTurbopackDOMEdge', () => {
9797
turbopackMap,
9898
);
9999
const response = ReactServerDOMClient.createFromReadableStream(stream, {
100-
ssrManifest: {
100+
serverManifest: {
101101
moduleMap: translationMap,
102102
moduleLoading: null,
103103
},

packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerNode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
} from '../shared/ReactFlightImportMetadata';
2525
import {prepareDestinationWithChunks} from 'react-client/src/ReactFlightClientConfig';
2626

27-
export type SSRModuleMap = {
27+
export type ServerConsumerModuleMap = {
2828
[clientId: string]: {
2929
[clientExportName: string]: ClientReference<any>,
3030
},
@@ -58,7 +58,7 @@ export function prepareDestinationForModule(
5858
}
5959

6060
export function resolveClientReference<T>(
61-
bundlerConfig: SSRModuleMap,
61+
bundlerConfig: ServerConsumerModuleMap,
6262
metadata: ClientReferenceMetadata,
6363
): ClientReference<T> {
6464
const moduleExports = bundlerConfig[metadata[ID]];

packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopack.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {prepareDestinationWithChunks} from 'react-client/src/ReactFlightClientCo
3030

3131
import {loadChunk} from 'react-client/src/ReactFlightClientConfig';
3232

33-
export type SSRModuleMap = null | {
33+
export type ServerConsumerModuleMap = null | {
3434
[clientId: string]: {
3535
[clientExportName: string]: ClientReferenceManifestEntry,
3636
},
@@ -63,7 +63,7 @@ export function prepareDestinationForModule(
6363
}
6464

6565
export function resolveClientReference<T>(
66-
bundlerConfig: SSRModuleMap,
66+
bundlerConfig: ServerConsumerModuleMap,
6767
metadata: ClientReferenceMetadata,
6868
): ClientReference<T> {
6969
if (bundlerConfig) {

packages/react-server-dom-turbopack/src/client/ReactFlightDOMClientEdge.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import type {
1717
import type {ReactServerValue} from 'react-client/src/ReactFlightReplyClient';
1818

1919
import type {
20-
SSRModuleMap,
20+
ServerConsumerModuleMap,
2121
ModuleLoading,
2222
} from 'react-client/src/ReactFlightClientConfig';
2323

24-
type SSRManifest = {
25-
moduleMap: SSRModuleMap,
24+
type ServerConsumerManifest = {
25+
moduleMap: ServerConsumerModuleMap,
2626
moduleLoading: ModuleLoading,
2727
};
2828

@@ -66,7 +66,7 @@ type EncodeFormActionCallback = <A>(
6666
) => ReactCustomFormAction;
6767

6868
export type Options = {
69-
ssrManifest: SSRManifest,
69+
serverManifest: ServerConsumerManifest,
7070
nonce?: string,
7171
encodeFormAction?: EncodeFormActionCallback,
7272
temporaryReferences?: TemporaryReferenceSet,
@@ -77,8 +77,8 @@ export type Options = {
7777

7878
function createResponseFromOptions(options: Options) {
7979
return createResponse(
80-
options.ssrManifest.moduleMap,
81-
options.ssrManifest.moduleLoading,
80+
options.serverManifest.moduleMap,
81+
options.serverManifest.moduleLoading,
8282
noServerCall,
8383
options.encodeFormAction,
8484
typeof options.nonce === 'string' ? options.nonce : undefined,

packages/react-server-dom-turbopack/src/client/ReactFlightDOMClientNode.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import type {
1515
} from 'react-client/src/ReactFlightClient';
1616

1717
import type {
18-
SSRModuleMap,
18+
ServerConsumerModuleMap,
1919
ModuleLoading,
2020
} from 'react-client/src/ReactFlightClientConfig';
2121

22-
type SSRManifest = {
23-
moduleMap: SSRModuleMap,
22+
type ServerConsumerManifest = {
23+
moduleMap: ServerConsumerModuleMap,
2424
moduleLoading: ModuleLoading,
2525
};
2626

@@ -66,12 +66,12 @@ export type Options = {
6666

6767
function createFromNodeStream<T>(
6868
stream: Readable,
69-
ssrManifest: SSRManifest,
69+
serverConsumerManifest: ServerConsumerManifest,
7070
options?: Options,
7171
): Thenable<T> {
7272
const response: Response = createResponse(
73-
ssrManifest.moduleMap,
74-
ssrManifest.moduleLoading,
73+
serverConsumerManifest.moduleMap,
74+
serverConsumerManifest.moduleLoading,
7575
noServerCall,
7676
options ? options.encodeFormAction : undefined,
7777
options && typeof options.nonce === 'string' ? options.nonce : undefined,

packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type Options = {
5858
clientReferences?: ClientReferencePath | $ReadOnlyArray<ClientReferencePath>,
5959
chunkName?: string,
6060
clientManifestFilename?: string,
61-
ssrManifestFilename?: string,
61+
serverConsumerManifestFilename?: string,
6262
};
6363

6464
const PLUGIN_NAME = 'React Server Plugin';
@@ -67,7 +67,7 @@ export default class ReactFlightWebpackPlugin {
6767
clientReferences: $ReadOnlyArray<ClientReferencePath>;
6868
chunkName: string;
6969
clientManifestFilename: string;
70-
ssrManifestFilename: string;
70+
serverConsumerManifestFilename: string;
7171

7272
constructor(options: Options) {
7373
if (!options || typeof options.isServer !== 'boolean') {
@@ -105,8 +105,8 @@ export default class ReactFlightWebpackPlugin {
105105
}
106106
this.clientManifestFilename =
107107
options.clientManifestFilename || 'react-client-manifest.json';
108-
this.ssrManifestFilename =
109-
options.ssrManifestFilename || 'react-ssr-manifest.json';
108+
this.serverConsumerManifestFilename =
109+
options.serverConsumerManifestFilename || 'react-ssr-manifest.json';
110110
}
111111

112112
apply(compiler: any) {
@@ -239,18 +239,18 @@ export default class ReactFlightWebpackPlugin {
239239
const clientManifest: {
240240
[string]: ImportManifestEntry,
241241
} = {};
242-
type SSRModuleMap = {
242+
type ServerConsumerModuleMap = {
243243
[string]: {
244244
[string]: {specifier: string, name: string},
245245
},
246246
};
247-
const moduleMap: SSRModuleMap = {};
247+
const moduleMap: ServerConsumerModuleMap = {};
248248
const ssrBundleConfig: {
249249
moduleLoading: {
250250
prefix: string,
251251
crossOrigin: string | null,
252252
},
253-
moduleMap: SSRModuleMap,
253+
moduleMap: ServerConsumerModuleMap,
254254
} = {
255255
moduleLoading: {
256256
prefix: compilation.outputOptions.publicPath || '',
@@ -374,7 +374,7 @@ export default class ReactFlightWebpackPlugin {
374374
);
375375
const ssrOutput = JSON.stringify(ssrBundleConfig, null, 2);
376376
compilation.emitAsset(
377-
_this.ssrManifestFilename,
377+
_this.serverConsumerManifestFilename,
378378
new sources.RawSource(ssrOutput, false),
379379
);
380380
},

0 commit comments

Comments
 (0)