Fix ProfilingPlugin for watch scenarios

This commit is contained in:
Mark Molinaro 2022-01-13 01:18:17 -08:00
parent 016ec7bcdb
commit 718bd9bc1e
6 changed files with 19 additions and 6 deletions

View File

@ -123,9 +123,7 @@ class Profiler {
* @returns {Trace} The trace object
*/
const createTrace = (fs, outputPath) => {
const trace = new Tracer({
noStream: true
});
const trace = new Tracer();
const profiler = new Profiler(inspector);
if (/\/|\\/.test(outputPath)) {
const dirPath = dirname(fs, outputPath);
@ -173,6 +171,7 @@ const createTrace = (fs, outputPath) => {
counter,
profiler,
end: callback => {
trace.push("]");
// Wait until the write stream finishes.
fsStream.on("close", () => {
callback();
@ -242,10 +241,10 @@ class ProfilingPlugin {
stage: Infinity
},
(stats, callback) => {
if (compiler.watchMode) return callback();
tracer.profiler.stopProfiling().then(parsedResults => {
if (parsedResults === undefined) {
tracer.profiler.destroy();
tracer.trace.flush();
tracer.end(callback);
return;
}
@ -293,7 +292,6 @@ class ProfilingPlugin {
});
tracer.profiler.destroy();
tracer.trace.flush();
tracer.end(callback);
});
}

View File

@ -396,7 +396,7 @@ const describeCases = config => {
done
)
) {
compiler.close();
compiler.close(() => {});
return;
}
compiler.close(done);

View File

@ -0,0 +1,3 @@
it("compiles", function() {
expect(WATCH_STEP).toBe("0");
})

View File

@ -0,0 +1,3 @@
it("should not crash on recompile", function() {
expect(WATCH_STEP).toBe("1");
})

View File

@ -0,0 +1,3 @@
module.exports = [
{ code: /DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK/ }
];

View File

@ -0,0 +1,6 @@
var webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [new webpack.debug.ProfilingPlugin()]
};