diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index a558320eca9ce..2723c7bedaa0e 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -334,6 +334,15 @@ export default async function getBaseWebpackConfig( return callback() } + // Relative requires don't need custom resolution, because they + // are relative to requests we've already resolved here. + // Absolute requires (require('/foo')) are extremely uncommon, but + // also have no need for customization as they're already resolved. + const start = request.charAt(0); + if (start === '.' || start === '/') { + return callback(); + } + // Resolve the import with the webpack provided context, this // ensures we're resolving the correct version when multiple // exist.