Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ export function getModuleDebugInfo<T>(
const debugInfo: ReactDebugInfo = [];
let i = 0;
while (i < chunks.length) {
const chunkFilename = chunks[i++];
addChunkDebugInfo(debugInfo, chunkFilename);
const chunk = chunks[i++];
// A merged chunk is `[mergedChunkFilename, ...]`; use its own filename.
addChunkDebugInfo(debugInfo, typeof chunk === 'string' ? chunk : chunk[0]);
}
return debugInfo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import type {
ReactAsyncInfo,
} from 'shared/ReactTypes';

export function loadChunk(filename: string): Promise<mixed> {
import type {Chunk} from '../shared/ReactFlightImportMetadata';

export function loadChunk(filename: Chunk): Promise<mixed> {
return __turbopack_load_by_url__(filename);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import type {ReactDebugInfo} from 'shared/ReactTypes';

export function loadChunk(filename: string): Promise<mixed> {
import type {Chunk} from '../shared/ReactFlightImportMetadata';

export function loadChunk(filename: Chunk): Promise<mixed> {
return __turbopack_load_by_url__(filename);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@

import {preinitScriptForSSR} from 'react-client/src/ReactFlightClientConfig';

import type {Chunk} from '../shared/ReactFlightImportMetadata';

export type ModuleLoading = null | {
prefix: string,
crossOrigin?: 'use-credentials' | '',
};

export function prepareDestinationWithChunks(
moduleLoading: ModuleLoading,
// Chunks are single-indexed filenames
chunks: Array<string>,
chunks: Array<Chunk>,
nonce: ?string,
) {
if (moduleLoading !== null) {
for (let i = 0; i < chunks.length; i++) {
const chunk = chunks[i];
// A merged chunk is `[mergedChunkFilename, ...]`; preinit its own URL.
preinitScriptForSSR(
moduleLoading.prefix + chunks[i],
moduleLoading.prefix + (typeof chunk === 'string' ? chunk : chunk[0]),
nonce,
moduleLoading.crossOrigin,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
* @flow
*/

// A chunk is either a plain chunk filename, or a merged chunk that bundles
// several component chunks together, emitted as
// `[mergedChunkFilename, componentChunkFilenames, componentChunkSizes]`.
export type Chunk =
| string
| [
/* merged chunk filename */ string,
/* component chunk filenames */ Array<string>,
/* component chunk sizes */ Array<number>,
];

export type ImportManifestEntry = {
id: string,
// chunks is an array of filenames
chunks: Array<string>,
chunks: Array<Chunk>,
name: string,
async?: boolean,
};
Expand All @@ -20,11 +30,11 @@ export type ImportManifestEntry = {
export type ImportMetadata =
| [
/* id */ string,
/* chunk filenames */ Array<string>,
/* chunks */ Array<Chunk>,
/* name */ string,
/* async */ 1,
]
| [/* id */ string, /* chunk filenames */ Array<string>, /* name */ string];
| [/* id */ string, /* chunks */ Array<Chunk>, /* name */ string];

export const ID = 0;
export const CHUNKS = 1;
Expand Down
6 changes: 5 additions & 1 deletion scripts/flow/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ declare const __webpack_require__: ((id: string) => any) & {
u: string => string,
};

declare function __turbopack_load_by_url__(id: string): Promise<mixed>;
// A chunk id is a plain filename, or a merged chunk emitted as
// `[mergedChunkFilename, componentChunkFilenames, componentChunkSizes]`.
declare function __turbopack_load_by_url__(
id: string | [string, Array<string>, Array<number>],
): Promise<mixed>;
declare const __turbopack_require__: ((id: string) => any) & {
u: string => string,
};
Expand Down
Loading