Skip to content

Commit 2bb6a62

Browse files
include null type in getRule param
1 parent a06e345 commit 2bb6a62

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/cloudflare/src/cli/build/patches/plugins/load-instrumentation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default class NextNodeServer extends BaseServer<
4545
}
4646
}`;
4747

48-
expect(patchCode(code, await getRule("_file_does_not_exist_"))).toMatchInlineSnapshot(`
48+
expect(patchCode(code, await getRule(null))).toMatchInlineSnapshot(`
4949
"export default class NextNodeServer extends BaseServer<
5050
Options,
5151
NodeNextRequest,

packages/cloudflare/src/cli/build/patches/plugins/load-instrumentation.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)