Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check hooks for existance before using in ProfilingPlugin #14698

Merged
merged 2 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/debug/ProfilingPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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));
}
});
Expand Down
5 changes: 4 additions & 1 deletion test/ProfilingPlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down