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 9f8b4d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
11 changes: 11 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,11 @@
export function renderToString() {
throw new Error(
`renderToString() is not supported when importing 'react-dom/server.edge' or 'react-dom/server.browser', use 'react-dom/server' instead.`
)
}

export function renderToStaticMarkup() {
throw new Error(
`renderToStaticMarkup() is not supported when importing 'react-dom/server.edge' or 'react-dom/server.browser', use 'react-dom/server' instead.`
)
}
3 changes: 3 additions & 0 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ 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 (!opts.isEdgeServer) {
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 9f8b4d8

Please sign in to comment.