Skip to content

Commit 81e20c3

Browse files
authored
feat(node): Allow to pass registerEsmLoaderHooks to preload (#12998)
As mentioned in here: #12912 (comment) there is no way today to exclude/include esm modules when preloading today. This PR adds the option to pass `registerEsmLoaderHooks` as option to `preloadOpenTelemetry`, which allows to exclude/include packages there as well. Users can then write their own custom `preload` script and configure this there, if wanted. ## Naming I chose to use the same option naming here than for `init`, although the semantics are a bit different - here we can't actually disable the wrapping (because that's the only reason to even call this). We can also use a different name if we want, but I thought this would maybe be easier to understand that this is the same thing 🤔
1 parent eb23dc4 commit 81e20c3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/node/src/sdk/initOtel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export function maybeInitializeEsmLoader(esmHookConfig?: EsmLoaderHookOptions):
6363
interface NodePreloadOptions {
6464
debug?: boolean;
6565
integrations?: string[];
66+
registerEsmLoaderHooks?: EsmLoaderHookOptions;
6667
}
6768

6869
/**
@@ -79,7 +80,7 @@ export function preloadOpenTelemetry(options: NodePreloadOptions = {}): void {
7980
}
8081

8182
if (!isCjs()) {
82-
maybeInitializeEsmLoader();
83+
maybeInitializeEsmLoader(options.registerEsmLoaderHooks);
8384
}
8485

8586
// These are all integrations that we need to pre-load to ensure they are set up before any other code runs

0 commit comments

Comments
 (0)