From d7626ffb7996463daf95f554ed30e67893741cf7 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 2 Oct 2023 17:22:22 -0700 Subject: [PATCH] Revert "misc: shortcut styled-jsx in external resolution (#56291)" (#56334) We can't resolve the exact URL in externals otherwise when you move from one path to another. x-ref: [slack thread](https://vercel.slack.com/archives/C04KC8A53T7/p1696291412072799?thread_ts=1695906014.899719&cid=C04KC8A53T7) This reverts commit dba978f4bac3a3f072dcbaff68bba3f75c2bbe15. --- packages/next/src/build/handle-externals.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/next/src/build/handle-externals.ts b/packages/next/src/build/handle-externals.ts index 4457155ce5720..a52f9dea1a021 100644 --- a/packages/next/src/build/handle-externals.ts +++ b/packages/next/src/build/handle-externals.ts @@ -301,8 +301,10 @@ export function makeExternalHandler({ return resolveResult.localRes } - if (request === 'styled-jsx/style' && !isAppLayer) { - return `commonjs ${defaultOverrides['styled-jsx/style']}` + // Forcedly resolve the styled-jsx installed by next.js, + // since `resolveExternal` cannot find the styled-jsx dep with pnpm + if (request === 'styled-jsx/style') { + resolveResult.res = defaultOverrides['styled-jsx/style'] } const { res, isEsm } = resolveResult