Unverified Commit cb5d0757 authored by Jimmy Lai's avatar Jimmy Lai Committed by GitHub

misc: fix bundling of experimental (#57311)

this removes the call to experimental static react when not using the experimental build
parent 4eaefbab
...@@ -19,8 +19,10 @@ export interface Renderer { ...@@ -19,8 +19,10 @@ export interface Renderer {
} }
class StaticRenderer implements Renderer { class StaticRenderer implements Renderer {
private readonly prerender = require('react-dom/static.edge') // this is for tree shaking. Couldn't find a better way to do it for some reason
.prerender as typeof import('react-dom/static.edge')['prerender'] private readonly prerender = (process.env.__NEXT_EXPERIMENTAL_REACT
? require('react-dom/static.edge').prerender
: null) as typeof import('react-dom/static.edge')['prerender']
public async render(children: JSX.Element, streamOptions: StreamOptions) { public async render(children: JSX.Element, streamOptions: StreamOptions) {
const { prelude, postponed } = await this.prerender(children, streamOptions) const { prelude, postponed } = await this.prerender(children, streamOptions)
......
...@@ -172,6 +172,9 @@ module.exports = ({ dev, turbo, bundleType, experimental }) => { ...@@ -172,6 +172,9 @@ module.exports = ({ dev, turbo, bundleType, experimental }) => {
'process.env.NODE_ENV': JSON.stringify( 'process.env.NODE_ENV': JSON.stringify(
dev ? 'development' : 'production' dev ? 'development' : 'production'
), ),
'process.env.__NEXT_EXPERIMENTAL_REACT': JSON.stringify(
experimental ? true : false
),
'process.env.NEXT_RUNTIME': JSON.stringify('nodejs'), 'process.env.NEXT_RUNTIME': JSON.stringify('nodejs'),
...(!dev ? { 'process.env.TURBOPACK': JSON.stringify(turbo) } : {}), ...(!dev ? { 'process.env.TURBOPACK': JSON.stringify(turbo) } : {}),
}), }),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment