Merge pull request #15157 from markjm/markjm/watch-mode-profile-plugin
Fix ProfilingPlugin for watch scenarios
This commit is contained in:
commit
bc80a83a7a
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
@ -346,11 +344,15 @@ const interceptAllJavascriptModulesPluginHooks = (compilation, tracer) => {
|
|||
|
||||
const makeInterceptorFor = (instance, tracer) => hookName => ({
|
||||
register: ({ name, type, context, fn }) => {
|
||||
const newFn = makeNewProfiledTapFn(hookName, tracer, {
|
||||
name,
|
||||
type,
|
||||
fn
|
||||
});
|
||||
const newFn =
|
||||
// Don't tap our own hooks to ensure stream can close cleanly
|
||||
name === pluginName
|
||||
? fn
|
||||
: makeNewProfiledTapFn(hookName, tracer, {
|
||||
name,
|
||||
type,
|
||||
fn
|
||||
});
|
||||
return {
|
||||
name,
|
||||
type,
|
||||
|
|
|
@ -396,7 +396,7 @@ const describeCases = config => {
|
|||
done
|
||||
)
|
||||
) {
|
||||
compiler.close();
|
||||
compiler.close(() => {});
|
||||
return;
|
||||
}
|
||||
compiler.close(done);
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
it("compiles", function() {
|
||||
expect(WATCH_STEP).toBe("0");
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
it("should not crash on recompile", function() {
|
||||
expect(WATCH_STEP).toBe("1");
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = [
|
||||
{ code: /DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK/ }
|
||||
];
|
|
@ -0,0 +1,6 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
plugins: [new webpack.debug.ProfilingPlugin()]
|
||||
};
|
Loading…
Reference in New Issue