From 17df1b3d08315bf7200b9657a0703110f927fe9f Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 6 Oct 2023 18:04:57 +0200 Subject: [PATCH] fix compiler type --- packages/next/src/build/handle-externals.ts | 6 +----- packages/next/src/build/webpack-config.ts | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/next/src/build/handle-externals.ts b/packages/next/src/build/handle-externals.ts index a52f9dea1a0219..d45bec5b2a3952 100644 --- a/packages/next/src/build/handle-externals.ts +++ b/packages/next/src/build/handle-externals.ts @@ -65,11 +65,7 @@ export async function resolveExternal( let preferEsmOptions = esmExternals && isEsmRequested ? [true, false] : [false] - // Disable esm resolving for app/ and pages/ so for esm package using under pages/ - // won't load react through esm loader - if (hasAppDir) { - preferEsmOptions = [false] - } + for (const preferEsm of preferEsmOptions) { const resolve = getResolve( preferEsm ? esmResolveOptions : nodeResolveOptions diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 5b802b6cdca5ef..5d3fbc33c0d5b9 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -1604,7 +1604,7 @@ export default async function getBaseWebpackConfig( ], }, resolve: { - mainFields: getMainField('app', 'server'), + mainFields: getMainField('app', compilerType), conditionNames: reactServerCondition, // If missing the alias override here, the default alias will be used which aliases // react to the direct file path, not the package name. In that case the condition @@ -1750,7 +1750,7 @@ export default async function getBaseWebpackConfig( exclude: [codeCondition.exclude], use: swcLoaderForClientLayer, resolve: { - mainFields: getMainField('app', 'server'), + mainFields: getMainField('app', compilerType), }, }, ]