forked from agegr/pi-web
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
16 lines (13 loc) · 818 Bytes
/
Copy pathinstrumentation.ts
File metadata and controls
16 lines (13 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import type { configureHttpDispatcher as ConfigureHttpDispatcher } from "@/lib/http-dispatcher";
type DispatcherModule = { configureHttpDispatcher: typeof ConfigureHttpDispatcher };
export async function register(): Promise<void> {
if (process.env.NEXT_RUNTIME !== "nodejs" || typeof process.versions.bun === "string") return;
// Keep the Node-only undici graph out of Next's browser/edge instrumentation
// bundles. Node 22 can load this local TypeScript module directly.
const importRuntimeModule = Function("specifier", "return import(specifier)") as (
specifier: string,
) => Promise<DispatcherModule>;
const moduleUrl = `file://${encodeURI(process.cwd())}/lib/http-dispatcher.ts`;
const { configureHttpDispatcher } = await importRuntimeModule(moduleUrl);
await configureHttpDispatcher();
}