-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fall back to
react-dom/server.browser
in Pages router when React 18…
… is installed React 18 has no `react-dom/server.edge`
- Loading branch information
Showing
4 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from 'react-dom/server.edge' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
let ReactDOMServer | ||
|
||
try { | ||
ReactDOMServer = require('react-dom/server.edge') | ||
} catch (error) { | ||
if ( | ||
// TODO: copilot suggestion. Does this code actually exist? | ||
error.code !== 'MODULE_NOT_FOUND' && | ||
// TODO: actually encountered that | ||
error.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED' | ||
) { | ||
throw error | ||
} | ||
// TODO: Ensure App Router does not bundle this | ||
// In React versions without react-dom/server.edge, the browser build works in Node.js. | ||
// The Node.js build does not support renderToReadableStream. | ||
ReactDOMServer = require('react-dom/server.browser') | ||
} | ||
|
||
module.exports = ReactDOMServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters