From 4c5e28c55184bf58ae425279e84de4fa9b293f51 Mon Sep 17 00:00:00 2001 From: miikis Date: Fri, 4 Nov 2022 21:36:08 -0700 Subject: [PATCH] fix(nextjs): guard against missing webpack-loader 'issuer' field Next.js v13+ removed the 'issuer' field from their css/sass loaders. This breaks the nx-next plugin 'withNx'. This PR just adds a check to ensure the 'issuer' field is still there. Not the most robust fix but it should at least maintain backwards-compatibility w/ folks using next.js < 13. ISSUES CLOSED: #12916, #12912 --- packages/next/plugins/with-nx.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index 7fe8d70265006..d8a0ff689c32b 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -79,7 +79,7 @@ export function withNx( rule.sideEffects === false && regexEqual(rule.test, /\.module\.css$/) ); // Might not be found if Next.js webpack config changes in the future - if (nextCssLoader) { + if (nextCssLoader && nextCssLoader.issuer) { nextCssLoader.issuer.or = nextCssLoader.issuer.and ? nextCssLoader.issuer.and.concat(includes) : includes; @@ -95,7 +95,7 @@ export function withNx( regexEqual(rule.test, /\.module\.(scss|sass)$/) ); // Might not be found if Next.js webpack config changes in the future - if (nextSassLoader) { + if (nextSassLoader && nextSassLoader.issuer) { nextSassLoader.issuer.or = nextSassLoader.issuer.and ? nextSassLoader.issuer.and.concat(includes) : includes;