Skip to content

Commit

Permalink
remove react dom legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
feedthejim committed Sep 27, 2023
1 parent 2ef5704 commit 6ce3b52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions packages/next/src/build/noop-react-dom-server-legacy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const ERROR_MESSAGE =
'Internal Error: do not use legacy react-dom/server APIs. If you encountered this error, please open an issue on the Next.js repo.'

export function renderToString() {
throw new Error(ERROR_MESSAGE)
}

export function renderToStaticMarkup() {
throw new Error(ERROR_MESSAGE)
}
1 change: 0 additions & 1 deletion packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ function createRSCAliases(
'react/jsx-dev-runtime$': `next/dist/server/future/route-modules/app-page/vendored/shared/react-jsx-dev-runtime`,
react$: `next/dist/server/future/route-modules/app-page/vendored/${opts.layer}/react`,
'react-dom$': `next/dist/server/future/route-modules/app-page/vendored/${opts.layer}/react-dom`,
'react-dom/server.edge$': `next/dist/server/future/route-modules/app-page/vendored/${opts.layer}/react-dom-server-edge`,
'react-server-dom-webpack/client.edge$': `next/dist/server/future/route-modules/app-page/vendored/${opts.layer}/react-server-dom-webpack-client-edge`,
})
} else if (opts.layer === WEBPACK_LAYERS.reactServerComponents) {
Expand Down
7 changes: 4 additions & 3 deletions packages/next/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const pagesExternals = [
]

function makeAppAliases(reactChannel = '') {
const alias = {
return {
react$: `next/dist/compiled/react${reactChannel}`,
'react/shared-subset$': `next/dist/compiled/react${reactChannel}/react.shared-subset`,
'react-dom/server-rendering-stub$': `next/dist/compiled/react-dom${reactChannel}/server-rendering-stub`,
Expand All @@ -36,9 +36,10 @@ function makeAppAliases(reactChannel = '') {
'react-server-dom-webpack/client.edge$': `next/dist/compiled/react-server-dom-webpack${reactChannel}/client.edge`,
'react-server-dom-webpack/server.edge$': `next/dist/compiled/react-server-dom-webpack${reactChannel}/server.edge`,
'react-server-dom-webpack/server.node$': `next/dist/compiled/react-server-dom-webpack${reactChannel}/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`,
}

return alias
}

const appAliases = makeAppAliases()
Expand Down

0 comments on commit 6ce3b52

Please sign in to comment.