Skip to content

Commit 678a182

Browse files
committed
proper NODE_ENV setting with explanation
1 parent da3702b commit 678a182

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/run/handlers/request-context.cts

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import { LogLevel, systemLogger } from '@netlify/functions/internal'
44

55
import type { NetlifyCachedRouteValue } from '../../shared/cache-types.cjs'
66

7-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
8-
// @ts-ignore - last remaining bit to fix
9-
// process.env.NODE_ENV = 'production'
10-
117
type SystemLogger = typeof systemLogger
128

139
export type RequestContext = {

src/run/next.cts

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ import { getRequestContext } from './handlers/request-context.cjs'
88
import { getTracer } from './handlers/tracer.cjs'
99
import { getRegionalBlobStore } from './regional-blob-store.cjs'
1010

11+
// https://github.com/vercel/next.js/pull/68193/files#diff-37243d614f1f5d3f7ea50bbf2af263f6b1a9a4f70e84427977781e07b02f57f1R49
12+
// This import resulted in importing unbundled React which depending if NODE_ENV is `production` or not would use
13+
// either development or production version of React. When not set to `production` it would use development version
14+
// which later cause mismatching problems when both development and production versions of React were loaded causing
15+
// react errors.
16+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
17+
// @ts-ignore ignoring readonly NODE_ENV
18+
process.env.NODE_ENV = 'production'
19+
1120
console.time('import next server')
1221

1322
// eslint-disable-next-line @typescript-eslint/no-var-requires

0 commit comments

Comments
 (0)