diff --git a/src/Walker.ts b/src/Walker.ts index 46cf1fd..28f5e5b 100644 --- a/src/Walker.ts +++ b/src/Walker.ts @@ -25,6 +25,7 @@ export class Walker { private rootModule: string; private modules: Module[]; private walkHistory: Set = new Set(); + private realPaths: Map = new Map(); constructor(modulePath: string) { if (!modulePath || typeof modulePath !== 'string') { @@ -51,7 +52,11 @@ export class Walker { } private async walkDependenciesForModuleInModule(moduleName: string, modulePath: string, depType: DepType) { - let testPath = modulePath; + let testPath = this.realPaths.get(modulePath); + if (!testPath) { + testPath = await fs.realpath(modulePath); + this.realPaths.set(modulePath, testPath); + } let discoveredPath: string | null = null; let lastRelative: string | null = null; // Try find it while searching recursively up the tree