Skip to content

Commit 1093cc8

Browse files
committed
ref: Remove dynamicRequire, Fix require call
1 parent 54cc984 commit 1093cc8

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

packages/hub/src/hub.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ export function getCurrentHub(): Hub {
454454
*/
455455
function getHubFromActiveDomain(registry: Carrier): Hub {
456456
try {
457-
const domain = require('domain');
457+
const req = require;
458+
const domain = req('domain');
458459
const activeDomain = domain.active;
459460

460461
// If there no active domain, just return global hub

packages/utils/src/misc.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ interface SentryGlobal {
2020
};
2121
}
2222

23-
/**
24-
* Requires a module which is protected against bundler minification.
25-
*
26-
* @param request The module path to resolve
27-
*/
28-
export function dynamicRequire(mod: any, request: string): any {
29-
// tslint:disable-next-line: no-unsafe-any
30-
return mod.require(request);
31-
}
32-
3323
/**
3424
* Checks whether we're in the Node.js or Browser environment
3525
*
@@ -375,7 +365,8 @@ const performanceFallback: CrossPlatformPerformance = {
375365
export const crossPlatformPerformance: CrossPlatformPerformance = (() => {
376366
if (isNodeEnv()) {
377367
try {
378-
const perfHooks = dynamicRequire(module, 'perf_hooks') as { performance: CrossPlatformPerformance };
368+
const req = require;
369+
const perfHooks = req('perf_hooks') as { performance: CrossPlatformPerformance };
379370
return perfHooks.performance;
380371
} catch (_) {
381372
return performanceFallback;

0 commit comments

Comments
 (0)