speed-measure-webpack-plugin
Advanced tools
Comparing version 0.3.2 to 0.3.3
{ | ||
"name": "speed-measure-webpack-plugin", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Measure + analyse the speed of your webpack loaders and plugins", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,4 +10,7 @@ let idInc = 0; | ||
// call, so we just set it multiple times, letting each one override the last | ||
const addEndEvent = () => | ||
let endCallCount = 0; | ||
const addEndEvent = () => { | ||
endCallCount++; | ||
smp.addTimeEvent("plugins", timeEventName, "end", { id }); | ||
}; | ||
@@ -22,4 +25,8 @@ smp.addTimeEvent("plugins", timeEventName, "start", { | ||
); | ||
addEndEvent(); | ||
// If the end event was invoked as a callback immediately, we can | ||
// don't want to add another end event here (and it can actually cause | ||
// errors, if webpack has finished compilation entirely) | ||
if (!endCallCount) addEndEvent(); | ||
return ret; | ||
@@ -50,15 +57,15 @@ }; | ||
const shouldWrap = getShouldWrap(orig); | ||
const shouldSoftWrap = Object.values(orig).some(getShouldWrap); | ||
const shouldSoftWrap = Object.keys(orig) | ||
.map(k => orig[k]) | ||
.some(getShouldWrap); | ||
if (!shouldWrap && !shouldSoftWrap) { | ||
const vanillaFunc = | ||
typeof orig === "function" && | ||
orig && | ||
orig.prototype && | ||
orig.prototype.constructor !== orig; | ||
const vanillaFunc = orig.name === "next"; | ||
return vanillaFunc | ||
? function() { | ||
const ret = orig(); | ||
// do this before calling the callback, since the callback can start | ||
// the next plugin step | ||
addEndEvent(); | ||
return ret; | ||
return orig.apply(this, arguments); | ||
} | ||
@@ -65,0 +72,0 @@ : orig; |
192927
422