From 471efadeca854b666ccae9abb31c59365b4e7eca Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Sat, 6 Feb 2021 22:52:18 +0100 Subject: [PATCH 1/2] Fix profiling plugin for next build --- .../build/webpack/plugins/profiling-plugin.ts | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/next/build/webpack/plugins/profiling-plugin.ts b/packages/next/build/webpack/plugins/profiling-plugin.ts index 0371f6e0d0474..36642628990a6 100644 --- a/packages/next/build/webpack/plugins/profiling-plugin.ts +++ b/packages/next/build/webpack/plugins/profiling-plugin.ts @@ -85,14 +85,24 @@ export class ProfilingPlugin { compiler.hooks.environment, compiler.hooks.afterEnvironment ) - this.traceHookPair( - 'webpack-invalidated', - compiler.hooks.invalid, - compiler.hooks.done - ) + if (compiler.options.mode === 'development') { + this.traceHookPair( + 'webpack-invalidated', + compiler.hooks.invalid, + compiler.hooks.done + ) + } } traceCompilationHooks(compiler: any) { + if (isWebpack5) { + this.traceHookPair( + 'webpack-compilation', + compiler.hooks.beforeCompile, + compiler.hooks.afterCompile + ) + } + compiler.hooks.compilation.tap(pluginName, (compilation: any) => { compilation.hooks.buildModule.tap(pluginName, (module: any) => { const compilerSpan = spans.get(compiler) @@ -118,14 +128,6 @@ export class ProfilingPlugin { spans.get(module).end() }) - if (isWebpack5) { - this.traceHookPair( - 'webpack-compilation', - compilation.hooks.beforeCompile, - compilation.hooks.afterCompile - ) - } - this.traceHookPair( 'webpack-compilation-chunk-graph', compilation.hooks.beforeChunks, From dd0a18e7d6e7b95c07d943bbd325eb074d2d98e2 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 9 Feb 2021 13:38:27 +0100 Subject: [PATCH 2/2] Add trace-debug command --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index aa124793cc3d5..8a001623e145d 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "lint-staged": "lint-staged", "next": "node --trace-deprecation 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" }, "pre-commit": "lint-staged",