| 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 | export type ImportManifestEntry = { |
| 11 | id: string, |
| 12 | // chunks is a double indexed array of chunkId / chunkFilename pairs |
| 13 | chunks: Array<string>, |
| 14 | name: string, |
| 15 | async?: boolean, |
| 16 | }; |
| 17 | |
| 18 | // This is the parsed shape of the wire format which is why it is |
| 19 | // condensed to only the essentialy information |
| 20 | export type ImportMetadata = |
| 21 | | [ |
| 22 | /* id */ string, |
| 23 | /* chunks id/filename pairs, double indexed */ Array<string>, |
| 24 | /* name */ string, |
| 25 | /* async */ 1, |
| 26 | ] |
| 27 | | [ |
| 28 | /* id */ string, |
| 29 | /* chunks id/filename pairs, double indexed */ Array<string>, |
| 30 | /* name */ string, |
| 31 | ]; |
| 32 | |
| 33 | export const ID = 0; |
| 34 | export const CHUNKS = 1; |
| 35 | export const NAME = 2; |
| 36 | // export const ASYNC = 3; |
| 37 | |
| 38 | // This logic is correct because currently only include the 4th tuple member |
| 39 | // when the module is async. If that changes we will need to actually assert |
| 40 | // the value is true. We don't index into the 4th slot because flow does not |
| 41 | // like the potential out of bounds access |
| 42 | export function isAsyncImport(metadata: ImportMetadata): boolean { |
| 43 | return metadata.length === 4; |
| 44 | } |