@@ -15,7 +15,10 @@ export function patchLoadInstrumentation(updater: ContentUpdater, buildOpts: Bui
1515
1616 const baseDir = join ( outputDir , "server-functions/default" , getPackagePath ( buildOpts ) ) ;
1717 const dotNextDir = join ( baseDir , ".next" ) ;
18- const builtInstrumentationPath = join ( dotNextDir , "server" , `${ INSTRUMENTATION_HOOK_FILENAME } .js` ) ;
18+ const maybeBuiltInstrumentationPath = join ( dotNextDir , "server" , `${ INSTRUMENTATION_HOOK_FILENAME } .js` ) ;
19+ const builtInstrumentationPath = existsSync ( maybeBuiltInstrumentationPath )
20+ ? maybeBuiltInstrumentationPath
21+ : null ;
1922
2023 return updater . updateContent (
2124 "patch-load-instrumentation" ,
@@ -24,7 +27,7 @@ export function patchLoadInstrumentation(updater: ContentUpdater, buildOpts: Bui
2427 ) ;
2528}
2629
27- export async function getRule ( builtInstrumentationPath : string ) {
30+ export async function getRule ( builtInstrumentationPath : string | null ) {
2831 return `
2932 rule:
3033 kind: method_definition
@@ -34,7 +37,7 @@ export async function getRule(builtInstrumentationPath: string) {
3437
3538 fix:
3639 async loadInstrumentationModule() {
37- this.instrumentation = ${ existsSync ( builtInstrumentationPath ) ? `require('${ builtInstrumentationPath } ')` : "null" } ;
40+ this.instrumentation = ${ builtInstrumentationPath ? `require('${ builtInstrumentationPath } ')` : "null" } ;
3841 return this.instrumentation;
3942 }
4043 ` ;
0 commit comments