From c0b105c91195692a70ba6323d3c14a08ab4772ee Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 14 Sep 2020 22:27:43 -0500 Subject: [PATCH] Update webpack 5 resolving (#17095) On the latest beta of webpack 5 resolving fails with the below error and according to https://github.com/webpack/webpack/issues/11467 is due to the imports in this module not being fully specified. This adds the config mentioned in the thread to correct the resolving for this module. ```sh Failed to compile. -- 16:33:50.046 | ModuleNotFoundError: Module not found: Error: Can't resolve './assertThisInitialized' in '/vercel/f03cc85/node_modules/@babel/runtime/helpers/esm' 16:33:50.046 | > Build error occurred 16:33:50.047 | Error: > Build failed because of webpack errors 16:33:50.047 | at build (/vercel/f03cc85/node_modules/next/dist/build/index.js:15:918) 16:33:50.099 | error Command failed with exit code 1. ``` --- packages/next/build/webpack-config.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 8f9753d16796e..780677c9f28bb 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -852,6 +852,18 @@ export default async function getBaseWebpackConfig( }, module: { rules: [ + ...(isWebpack5 + ? [ + // TODO: FIXME: do NOT webpack 5 support with this + // x-ref: https://github.com/webpack/webpack/issues/11467 + { + test: /\.m?js/, + resolve: { + fullySpecified: false, + }, + } as any, + ] + : []), { test: /\.(tsx|ts|js|mjs|jsx)$/, include: [dir, ...babelIncludeRegexes],