Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 9738806

Browse files
committed
fix: emit runtime files and entry point files
1 parent a0c4245 commit 9738806

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

Diff for: plugins/WatchStateLoggerPlugin.ts

+43-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,51 @@ export class WatchStateLoggerPlugin {
3333
.keys(compilation.assets)
3434
.filter(assetKey => compilation.assets[assetKey].emitted);
3535

36+
const webpackRuntimeFiles = getWebpackRuntimeOnlyFiles(compilation);
37+
const entryPointFiles = getEntryPointFiles(compilation);
38+
3639
process.send && process.send(messages.compilationComplete, error => null);
3740
// Send emitted files so they can be LiveSynced if need be
38-
process.send && process.send({ emittedFiles }, error => null);
41+
process.send && process.send({ emittedFiles, webpackRuntimeFiles, entryPointFiles }, error => null);
3942
});
4043
}
4144
}
45+
46+
function getWebpackRuntimeOnlyFiles(compilation) {
47+
let runtimeOnlyFiles = [];
48+
try {
49+
runtimeOnlyFiles = [].concat(...Array.from<any>(compilation.entrypoints.values())
50+
.map(entrypoint => entrypoint.runtimeChunk)
51+
// filter embedded runtime chunks (e.g. part of bundle.js or inspector-modules.js)
52+
.filter(runtimeChunk => !!runtimeChunk && runtimeChunk.preventIntegration)
53+
.map(runtimeChunk => runtimeChunk.files))
54+
// get only the unique files in case of "single" runtime (e.g. runtime.js)
55+
.filter((value, index, self) => self.indexOf(value) === index);
56+
} catch (e) {
57+
// breaking change in the Webpack API
58+
console.log("Warning: Unable to find Webpack runtime files.");
59+
}
60+
61+
return runtimeOnlyFiles;
62+
}
63+
64+
function getEntryPointFiles(compilation) {
65+
const entryPointFiles = [];
66+
try {
67+
Array.from(compilation.entrypoints.values())
68+
.forEach((entrypoint: any) => {
69+
const entryChunk = entrypoint.chunks.find(chunk => chunk.name === entrypoint.options.name);
70+
if (entryChunk) {
71+
entryChunk.files.forEach(fileName => {
72+
if (fileName.indexOf("hot-update") === -1) {
73+
entryPointFiles.push(fileName);
74+
}
75+
});
76+
}
77+
});
78+
} catch (e) {
79+
console.log("Warning: Unable to find Webpack entry point files.");
80+
}
81+
82+
return entryPointFiles;
83+
}

0 commit comments

Comments
 (0)