@@ -101,6 +101,12 @@ import { loadManifest } from './load-manifest'
101
101
102
102
export * from './base-server'
103
103
104
+ declare const __non_webpack_require__ : NodeRequire
105
+
106
+ const dynamicRequire = process . env . NEXT_MINIMAL
107
+ ? __non_webpack_require__
108
+ : require
109
+
104
110
function writeStdoutLine ( text : string ) {
105
111
process . stdout . write ( ' ' + text + '\n' )
106
112
}
@@ -244,12 +250,15 @@ export default class NextNodeServer extends BaseServer {
244
250
this . nextConfig . experimental . instrumentationHook
245
251
) {
246
252
try {
247
- const instrumentationHook = await require ( resolve (
248
- this . serverOptions . dir || '.' ,
249
- this . serverOptions . conf . distDir ! ,
250
- 'server' ,
251
- INSTRUMENTATION_HOOK_FILENAME
252
- ) )
253
+ const instrumentationHook = await dynamicRequire (
254
+ resolve (
255
+ this . serverOptions . dir || '.' ,
256
+ this . serverOptions . conf . distDir ! ,
257
+ 'server' ,
258
+ INSTRUMENTATION_HOOK_FILENAME
259
+ )
260
+ )
261
+
253
262
await instrumentationHook . register ?.( )
254
263
} catch ( err : any ) {
255
264
if ( err . code !== 'MODULE_NOT_FOUND' ) {
@@ -289,9 +298,11 @@ export default class NextNodeServer extends BaseServer {
289
298
const { incrementalCacheHandlerPath } = this . nextConfig . experimental
290
299
291
300
if ( incrementalCacheHandlerPath ) {
292
- CacheHandler = require ( isAbsolute ( incrementalCacheHandlerPath )
293
- ? incrementalCacheHandlerPath
294
- : join ( this . distDir , incrementalCacheHandlerPath ) )
301
+ CacheHandler = dynamicRequire (
302
+ isAbsolute ( incrementalCacheHandlerPath )
303
+ ? incrementalCacheHandlerPath
304
+ : join ( this . distDir , incrementalCacheHandlerPath )
305
+ )
295
306
CacheHandler = CacheHandler . default || CacheHandler
296
307
}
297
308
0 commit comments