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
|
||||
Object.keys(compiler.hooks).forEach(hookName => {
|
||||
compiler.hooks[hookName].intercept(
|
||||
makeInterceptorFor("Compiler", tracer)(hookName)
|
||||
);
|
||||
const hook = compiler.hooks[hookName];
|
||||
if (hook) {
|
||||
hook.intercept(makeInterceptorFor("Compiler", tracer)(hookName));
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(compiler.resolverFactory.hooks).forEach(hookName => {
|
||||
compiler.resolverFactory.hooks[hookName].intercept(
|
||||
makeInterceptorFor("Resolver", tracer)(hookName)
|
||||
);
|
||||
const hook = compiler.resolverFactory.hooks[hookName];
|
||||
if (hook) {
|
||||
hook.intercept(makeInterceptorFor("Resolver", tracer)(hookName));
|
||||
}
|
||||
});
|
||||
|
||||
compiler.hooks.compilation.tap(
|
||||
|
@ -303,7 +305,7 @@ const interceptAllHooksFor = (instance, tracer, logLabel) => {
|
|||
if (Reflect.has(instance, "hooks")) {
|
||||
Object.keys(instance.hooks).forEach(hookName => {
|
||||
const hook = instance.hooks[hookName];
|
||||
if (!hook._fakeHook) {
|
||||
if (hook && !hook._fakeHook) {
|
||||
hook.intercept(makeInterceptorFor(logLabel, tracer)(hookName));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,7 +25,10 @@ describe("Profiling Plugin", function () {
|
|||
new webpack.debug.ProfilingPlugin({
|
||||
outputPath: finalPath
|
||||
})
|
||||
]
|
||||
],
|
||||
experiments: {
|
||||
backCompat: false
|
||||
}
|
||||
});
|
||||
compiler.run(err => {
|
||||
if (err) return done(err);
|
||||
|
|
Loading…
Reference in New Issue