Skip to content

Commit 80aca67

Browse files
authored
fix: esbuild warning dynamic require (#3164)
1 parent 58d2d78 commit 80aca67

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/node/src/integrations/modules.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ import { dirname, join } from 'path';
44

55
let moduleCache: { [key: string]: string };
66

7+
/** Extract information about paths */
8+
function getPaths(): string[] {
9+
try {
10+
return require.cache ? Object.keys(require.cache as Record<string, unknown>) : [];
11+
} catch (e) {
12+
return [];
13+
}
14+
}
15+
716
/** Extract information about package.json modules */
817
function collectModules(): {
918
[name: string]: string;
1019
} {
1120
const mainPaths = (require.main && require.main.paths) || [];
12-
const paths = require.cache ? Object.keys(require.cache as Record<string, unknown>) : [];
21+
const paths = getPaths();
1322
const infos: {
1423
[name: string]: string;
1524
} = {};

0 commit comments

Comments
 (0)