Skip to content

Commit

Permalink
Improve caching for relative paths in module resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Nov 30, 2023
1 parent f947b0a commit 6292c7f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/knip/src/typescript/resolveModuleNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export function createCustomModuleResolver(
) {
function resolveModuleNames(moduleNames: string[], containingFile: string): Array<ts.ResolvedModuleFull | undefined> {
return moduleNames.map(moduleName => {
const key = `${containingFile}:${moduleName}`;
const key = moduleName.startsWith('.')
? join(dirname(containingFile), moduleName)
: `${containingFile}:${moduleName}`;
if (resolutionCache.has(key)) return resolutionCache.get(key)!;
const resolvedModule = resolveModuleName(moduleName, containingFile);
resolutionCache.set(key, resolvedModule);
Expand Down

0 comments on commit 6292c7f

Please sign in to comment.