From 9b71c53e4353b4fdc9ebd1ca122cf7dbf994f040 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Wed, 23 Nov 2022 11:21:25 -0500 Subject: [PATCH] fix(nextjs): check validity of Nx context in withNx plugin (#13358) (cherry picked from commit dc1646860779f9ecfb7550a645ceb639a5ca20b7) --- packages/next/plugins/with-nx.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index 135b4db94bc4c..d750a6f13f117 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -38,6 +38,10 @@ export function withNx( nextConfig = {} as WithNxOptions, context: WithNxContext = getWithNxContext() ): NextConfig { + // If `next-compose-plugins` is used, the context argument is invalid. + if (!context.libsDir || !context.workspaceRoot) { + context = getWithNxContext(); + } const userWebpack = nextConfig.webpack || ((x) => x); const { nx, ...validNextConfig } = nextConfig; return {