Skip to content

Commit

Permalink
fix: esbuild warning dynamic require (#3164)
Browse files Browse the repository at this point in the history
  • Loading branch information
doktor500 committed Jan 12, 2021
1 parent 58d2d78 commit 80aca67
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/node/src/integrations/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ import { dirname, join } from 'path';

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

/** Extract information about paths */
function getPaths(): string[] {
try {
return require.cache ? Object.keys(require.cache as Record<string, unknown>) : [];
} catch (e) {
return [];
}
}

/** Extract information about package.json modules */
function collectModules(): {
[name: string]: string;
} {
const mainPaths = (require.main && require.main.paths) || [];
const paths = require.cache ? Object.keys(require.cache as Record<string, unknown>) : [];
const paths = getPaths();
const infos: {
[name: string]: string;
} = {};
Expand Down

0 comments on commit 80aca67

Please sign in to comment.