Unverified Commit 6b99bda3 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Fix profiling plugin for next build (#21989)

Makes sure `yarn trace build` works.
parent fa8ab993
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"next": "node --trace-deprecation packages/next/dist/bin/next", "next": "node --trace-deprecation packages/next/dist/bin/next",
"trace": "node --trace-deprecation -r ./bench/instrument.js packages/next/dist/bin/next", "trace": "node --trace-deprecation -r ./bench/instrument.js packages/next/dist/bin/next",
"trace-debug": "node --inspect --trace-deprecation -r ./bench/instrument.js packages/next/dist/bin/next",
"debug": "node --inspect packages/next/dist/bin/next" "debug": "node --inspect packages/next/dist/bin/next"
}, },
"pre-commit": "lint-staged", "pre-commit": "lint-staged",
......
...@@ -85,14 +85,24 @@ export class ProfilingPlugin { ...@@ -85,14 +85,24 @@ export class ProfilingPlugin {
compiler.hooks.environment, compiler.hooks.environment,
compiler.hooks.afterEnvironment compiler.hooks.afterEnvironment
) )
this.traceHookPair( if (compiler.options.mode === 'development') {
'webpack-invalidated', this.traceHookPair(
compiler.hooks.invalid, 'webpack-invalidated',
compiler.hooks.done compiler.hooks.invalid,
) compiler.hooks.done
)
}
} }
traceCompilationHooks(compiler: any) { traceCompilationHooks(compiler: any) {
if (isWebpack5) {
this.traceHookPair(
'webpack-compilation',
compiler.hooks.beforeCompile,
compiler.hooks.afterCompile
)
}
compiler.hooks.compilation.tap(pluginName, (compilation: any) => { compiler.hooks.compilation.tap(pluginName, (compilation: any) => {
compilation.hooks.buildModule.tap(pluginName, (module: any) => { compilation.hooks.buildModule.tap(pluginName, (module: any) => {
const compilerSpan = spans.get(compiler) const compilerSpan = spans.get(compiler)
...@@ -118,14 +128,6 @@ export class ProfilingPlugin { ...@@ -118,14 +128,6 @@ export class ProfilingPlugin {
spans.get(module).end() spans.get(module).end()
}) })
if (isWebpack5) {
this.traceHookPair(
'webpack-compilation',
compilation.hooks.beforeCompile,
compilation.hooks.afterCompile
)
}
this.traceHookPair( this.traceHookPair(
'webpack-compilation-chunk-graph', 'webpack-compilation-chunk-graph',
compilation.hooks.beforeChunks, compilation.hooks.beforeChunks,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment