-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fallback to
react-dom/server.browser
in Pages router if Edge versio…
…n is not available `react-dom/server.edge` is not available in React 18. We were using `.browser` before when we were on React 18 so this should be safe.
- Loading branch information
Showing
4 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/next/src/build/shims/ReactDOMServerEdgeIfAvailable.d.ts
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' |
18 changes: 18 additions & 0 deletions
18
packages/next/src/build/shims/ReactDOMServerEdgeIfAvailable.js
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,18 @@ | ||
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 | ||
} | ||
// TOOD: Ensure App Router does not bundle this | ||
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