mirror of https://github.com/webpack/webpack.git
Merge pull request #14698 from webpack/bugfix/profiling-plugin-hook-check
check hooks for existance before using in ProfilingPlugin
This commit is contained in:
commit
d96f23e9b0
|
@ -203,15 +203,17 @@ class ProfilingPlugin {
|
||||||
|
|
||||||
// Compiler Hooks
|
// Compiler Hooks
|
||||||
Object.keys(compiler.hooks).forEach(hookName => {
|
Object.keys(compiler.hooks).forEach(hookName => {
|
||||||
compiler.hooks[hookName].intercept(
|
const hook = compiler.hooks[hookName];
|
||||||
makeInterceptorFor("Compiler", tracer)(hookName)
|
if (hook) {
|
||||||
);
|
hook.intercept(makeInterceptorFor("Compiler", tracer)(hookName));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(compiler.resolverFactory.hooks).forEach(hookName => {
|
Object.keys(compiler.resolverFactory.hooks).forEach(hookName => {
|
||||||
compiler.resolverFactory.hooks[hookName].intercept(
|
const hook = compiler.resolverFactory.hooks[hookName];
|
||||||
makeInterceptorFor("Resolver", tracer)(hookName)
|
if (hook) {
|
||||||
);
|
hook.intercept(makeInterceptorFor("Resolver", tracer)(hookName));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
compiler.hooks.compilation.tap(
|
compiler.hooks.compilation.tap(
|
||||||
|
@ -303,7 +305,7 @@ const interceptAllHooksFor = (instance, tracer, logLabel) => {
|
||||||
if (Reflect.has(instance, "hooks")) {
|
if (Reflect.has(instance, "hooks")) {
|
||||||
Object.keys(instance.hooks).forEach(hookName => {
|
Object.keys(instance.hooks).forEach(hookName => {
|
||||||
const hook = instance.hooks[hookName];
|
const hook = instance.hooks[hookName];
|
||||||
if (!hook._fakeHook) {
|
if (hook && !hook._fakeHook) {
|
||||||
hook.intercept(makeInterceptorFor(logLabel, tracer)(hookName));
|
hook.intercept(makeInterceptorFor(logLabel, tracer)(hookName));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,7 +25,10 @@ describe("Profiling Plugin", function () {
|
||||||
new webpack.debug.ProfilingPlugin({
|
new webpack.debug.ProfilingPlugin({
|
||||||
outputPath: finalPath
|
outputPath: finalPath
|
||||||
})
|
})
|
||||||
]
|
],
|
||||||
|
experiments: {
|
||||||
|
backCompat: false
|
||||||
|
}
|
||||||
});
|
});
|
||||||
compiler.run(err => {
|
compiler.run(err => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
|
Loading…
Reference in New Issue