From e42a3d6d483ba0704c2133ebd7a8786e411be1f8 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Fri, 17 Mar 2023 23:35:02 +0100 Subject: [PATCH] Fix loader rule with wrong matching conditions (#47261 This Webpack loader rule should have the exactly same conditions as https://github.com/vercel/next.js/blob/828fd5a162b02c41cbfbef539688ae454594f24c/packages/next/src/build/webpack-config.ts#L1940-L1951 Except that it matches 2 special layers and an extra loader. --- packages/next/src/build/webpack-config.ts | 8 +++++--- .../ReactRefreshLogBox-builtins.test.ts.snap | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 51e5ad00d00d..af45f5c9770e 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -1917,18 +1917,20 @@ export default async function getBaseWebpackConfig( use: swcLoaderForServerLayer, }, { - test: codeCondition.test, + ...codeCondition, issuerLayer: { or: [WEBPACK_LAYERS.client, WEBPACK_LAYERS.appClient], }, - exclude: [staticGenerationAsyncStorageRegex], + exclude: [ + staticGenerationAsyncStorageRegex, + codeCondition.exclude, + ], use: [ ...(dev && isClient ? [ require.resolve( 'next/dist/compiled/@next/react-refresh-utils/dist/loader' ), - defaultLoaders.babel, ] : []), { diff --git a/test/development/acceptance-app/__snapshots__/ReactRefreshLogBox-builtins.test.ts.snap b/test/development/acceptance-app/__snapshots__/ReactRefreshLogBox-builtins.test.ts.snap index ee19fa4f4749..9ba9510722cd 100644 --- a/test/development/acceptance-app/__snapshots__/ReactRefreshLogBox-builtins.test.ts.snap +++ b/test/development/acceptance-app/__snapshots__/ReactRefreshLogBox-builtins.test.ts.snap @@ -41,7 +41,7 @@ https://nextjs.org/docs/messages/module-not-found" `; exports[`ReactRefreshLogBox app default Node.js builtins 1`] = ` -"./node_modules/my-package/index.js:2:22 +"./node_modules/my-package/index.js:2:0 Module not found: Can't resolve 'dns' https://nextjs.org/docs/messages/module-not-found