2018-12-13 00:00:46 +00:00
|
|
|
export type ManifestItem = {
|
2018-12-06 21:34:53 +00:00
|
|
|
id: number|string,
|
|
|
|
name: string,
|
|
|
|
file: string,
|
|
|
|
publicPath: string
|
|
|
|
}
|
|
|
|
|
2018-12-18 16:12:49 +00:00
|
|
|
export type Manifest = {[moduleId: string]: ManifestItem[]}
|
2018-12-06 21:34:53 +00:00
|
|
|
|
|
|
|
type DynamicImportBundles = Set<ManifestItem>
|
|
|
|
|
|
|
|
// Based on https://github.com/jamiebuilds/react-loadable/pull/132
|
|
|
|
export function getDynamicImportBundles (manifest: Manifest, moduleIds: string[]): DynamicImportBundles {
|
|
|
|
return moduleIds.reduce((bundles: DynamicImportBundles, moduleId: string): DynamicImportBundles => {
|
|
|
|
if (typeof manifest[moduleId] === 'undefined') {
|
|
|
|
return bundles
|
|
|
|
}
|
|
|
|
|
|
|
|
manifest[moduleId].map((item) => bundles.add(item))
|
|
|
|
return bundles
|
|
|
|
}, new Set())
|
|
|
|
}
|