From 1e65cc31086c5d7b618c3f9bded6ce56541db2c1 Mon Sep 17 00:00:00 2001 From: Nicholas Cunningham Date: Tue, 25 Apr 2023 11:04:12 -0600 Subject: [PATCH] fix(nextjs): Add debug ability when verbose is passed to build --- packages/next/src/executors/build/build.impl.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/next/src/executors/build/build.impl.ts b/packages/next/src/executors/build/build.impl.ts index fde35c4b31c47e..67a7519916705a 100644 --- a/packages/next/src/executors/build/build.impl.ts +++ b/packages/next/src/executors/build/build.impl.ts @@ -45,7 +45,18 @@ export default async function buildExecutor( (process.env as any).__NEXT_REACT_ROOT ||= 'true'; } - await build(root); + // Get the installed Next.js version (will be removed after Nx 16 and Next.js update) + const nextVersion = require('next/package.json')?.version ?? ''; + + // Check the major and minor version numbers + const [major, minor, _] = nextVersion.split('.'); + if (+major <= 13 && +minor < 2) { + // If the version is 13.1.x or lower, use the second parameter as the config object + await build(root, null, false, !!process.env.NX_VERBOSE_LOGGING); + } else { + // Otherwise, use the third parameter as a boolean flag for verbose logging + await build(root, false, !!process.env.NX_VERBOSE_LOGGING); + } if (!directoryExists(options.outputPath)) { mkdir(options.outputPath);