From 59ae828b48f396865bd7ffe5ad6bf620cb7f8355 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Sat, 27 Apr 2024 23:38:23 +0200 Subject: [PATCH] Again the react vs next/dist/compiled/react shenanigans --- .../next/src/build/create-compiler-aliases.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/next/src/build/create-compiler-aliases.ts b/packages/next/src/build/create-compiler-aliases.ts index bd357e605ca0e..7d6b0b4d50586 100644 --- a/packages/next/src/build/create-compiler-aliases.ts +++ b/packages/next/src/build/create-compiler-aliases.ts @@ -118,7 +118,8 @@ export function createWebpackAliases({ } : undefined), - next: NEXT_PROJECT_ROOT, + // Bad! Would take precedence over alias `next/dist/compiled/react` in `createRSCAliases` + // next: NEXT_PROJECT_ROOT, 'styled-jsx/style$': defaultOverrides['styled-jsx/style'], 'styled-jsx$': defaultOverrides['styled-jsx'], @@ -291,19 +292,32 @@ export function createRSCAliases( } if (isEdgeServer) { + // Why do we need these? Why aren't these resolved via import conditions? if (layer === WEBPACK_LAYERS.reactServerComponents) { alias[ 'react$' ] = `next/dist/compiled/react${bundledReactChannel}/react.react-server` + alias[ + 'next/dist/compiled/react$' + ] = `next/dist/compiled/react${bundledReactChannel}/react.react-server` alias[ 'react/jsx-runtime$' ] = `next/dist/compiled/react${bundledReactChannel}/jsx-runtime.react-server` + alias[ + 'next/dist/compiled/react/jsx-runtime$' + ] = `next/dist/compiled/react${bundledReactChannel}/jsx-runtime.react-server` alias[ 'react/jsx-dev-runtime$' ] = `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime.react-server` + alias[ + 'next/dist/compiled/react/jsx-dev-runtime$' + ] = `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime.react-server` alias[ 'react-dom$' ] = `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server` + alias[ + 'next/dist/compiled/react-dom$' + ] = `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server` } }