From 4eaefbab66120d6c84f6e731d28265c3c25e1e1e Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Mon, 23 Oct 2023 19:18:27 -0700 Subject: [PATCH] Optimize server bundle size (#57305) These are not used by the Next.js server and can save up to 15% size of the base Edge worker by ignoring them. --- packages/next/src/build/create-compiler-aliases.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/next/src/build/create-compiler-aliases.ts b/packages/next/src/build/create-compiler-aliases.ts index 73554e90976d5..ef96384b57f08 100644 --- a/packages/next/src/build/create-compiler-aliases.ts +++ b/packages/next/src/build/create-compiler-aliases.ts @@ -260,6 +260,9 @@ export function createRSCAliases( 'react-server-dom-webpack/client.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/client.edge`, 'react-server-dom-webpack/server.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/server.edge`, 'react-server-dom-webpack/server.node$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/server.node`, + // optimisations to ignore the legacy build of react-dom/server + './cjs/react-dom-server-legacy.browser.production.min.js': `next/dist/build/noop-react-dom-server-legacy`, + './cjs/react-dom-server-legacy.browser.development.js': `next/dist/build/noop-react-dom-server-legacy`, } if (!isEdgeServer) {