Skip to content

Commit 43d76c9

Browse files
committed
Check for not dev only
1 parent 1784ddd commit 43d76c9

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

packages/next/src/server/next-server.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -189,21 +189,24 @@ export default class NextNodeServer extends BaseServer<
189189
// Initialize super class
190190
super(options)
191191

192+
const isDev = options.dev ?? false
193+
this.isDev = isDev
194+
this.sriEnabled = Boolean(options.conf.experimental?.sri?.algorithm)
195+
192196
const isTurbopackBuild = this.isTurbopackBuild()
193197

194-
if (process.env.TURBOPACK && !isTurbopackBuild) {
195-
throw new Error(
196-
`Invariant: --turbopack is set but the build used Webpack`
197-
)
198-
} else if (!process.env.TURBOPACK && isTurbopackBuild) {
199-
throw new Error(
200-
`Invariant: --turbopack is not set but the build used Turbopack. Add --turbopack to "next start".`
201-
)
198+
if (!isDev) {
199+
if (process.env.TURBOPACK && !isTurbopackBuild) {
200+
throw new Error(
201+
`Invariant: --turbopack is set but the build used Webpack`
202+
)
203+
} else if (!process.env.TURBOPACK && isTurbopackBuild) {
204+
throw new Error(
205+
`Invariant: --turbopack is not set but the build used Turbopack. Add --turbopack to "next start".`
206+
)
207+
}
202208
}
203209

204-
this.isDev = options.dev ?? false
205-
this.sriEnabled = Boolean(options.conf.experimental?.sri?.algorithm)
206-
207210
/**
208211
* This sets environment variable to be used at the time of SSR by head.tsx.
209212
* Using this from process.env allows targeting SSR by calling

0 commit comments

Comments
 (0)