in packages/next/plugin-webpack5-os/src/MultiEntryManifest.ts [29:72]
private compileMultiEntry(compiler: Compiler, compilation: Compilation) {
const webpackConfig = compiler.options;
const manifestStr = compilation.assets[this.options.entryName];
const manifest = JSON.parse(manifestStr.source().toString());
if (isObject(webpackConfig.entry) && webpackConfig.output?.path) {
// process the json
const entries = Object.keys(webpackConfig.entry);
if (entries.length === 1) {
return;
}
entries.forEach((entryId) => {
if (!manifest.entrypoints[entryId]) {
return;
}
// @ts-ignore
Object.values(manifest.entrypoints[entryId]).forEach((entryPaths: string[]) => {
entryPaths.forEach((entryPath) => {
if (!compilation.assets[entryPath]) {
return;
}
// @ts-ignore
compilation.assets[entryPath] = new RawSource(
(compilation.assets[entryPath].source() as string).replace(
`window.__CONSOLE_OS_GLOBAL_HOOK__("${this.options.entryName.replace('.manifest.json', '')}`,
`window.__CONSOLE_OS_GLOBAL_HOOK__("${entryId}`,
),
);
});
});
// @ts-ignore
compilation.assets[`${entryId}.manifest.json`] = new RawSource(JSON.stringify({
...manifest,
name: entryId,
entrypoints: {
[entryId]: manifest.entrypoints[entryId],
},
}, null, 2));
});
}
}