Skip to content

Commit 2931bb8

Browse files
committed
hi dynamicResolve
1 parent 1193694 commit 2931bb8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/node/src/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getCurrentHub, initAndBind, Integrations as CoreIntegrations } from '@sentry/core';
22
import { getMainCarrier, setHubOnCarrier } from '@sentry/hub';
33
import { Integration } from '@sentry/types';
4-
import { dynamicRequire, getGlobalObject } from '@sentry/utils';
4+
import { dynamicRequire, dynamicResolve, getGlobalObject } from '@sentry/utils';
55
import * as domain from 'domain';
66
import { cwd } from 'process';
77
import * as readPkgUp from 'read-pkg-up';
@@ -142,7 +142,7 @@ function discoverIntegrations(): Integration[] {
142142
return /^@sentry\/integration-(common|node)-[a-z]/.test(name);
143143
})
144144
.map(name => {
145-
const mod = dynamicRequire(module, require.resolve(name, { paths: [cwd()] }));
145+
const mod = dynamicRequire(module, dynamicResolve(module, name, { paths: [cwd()] }));
146146
return Object.values(mod) as { new (): Integration }[];
147147
})
148148
.reduce((acc, integrations) => {

packages/utils/src/node.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ export function isNodeEnv(): boolean {
1212
*
1313
* @param request The module path to resolve
1414
*/
15-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
1615
export function dynamicRequire(mod: any, request: string): any {
17-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1816
return mod.require(request);
1917
}
18+
19+
/**
20+
* Resolves a module which is protected against bundler minification.
21+
*
22+
* @param request The module path to resolve
23+
* @param options The resolution options
24+
*/
25+
export function dynamicResolve(mod: any, request: string, options: Record<string, unknown>): any {
26+
return mod.require.resolve(request, options);
27+
}

0 commit comments

Comments
 (0)