Skip to content

Commit

Permalink
fix(nextjs): guard against missing webpack-loader 'issuer' field
Browse files Browse the repository at this point in the history
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: nrwl#12916, nrwl#12912
  • Loading branch information
Miikis committed Nov 5, 2022
1 parent 39518e3 commit 4c5e28c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/next/plugins/with-nx.ts
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 4c5e28c

Please sign in to comment.