Summary
Cache the results of getRelativeImportSpecifier() so repeated file pair lookups reuse previously computed relative paths.
Proposed Solution
const relativePathCache = new Map<string, string>();
function getCachedRelativeImportSpecifier(
fromFile: string,
toFile: string,
): string {
const cacheKey = `${fromFile}|${toFile}`;
let result = relativePathCache.get(cacheKey);
if (result === undefined) {
result = getRelativeImportSpecifier(fromFile, toFile);
relativePathCache.set(cacheKey, result);
}
return result;
}
- Normalise file paths before building the cache key.
- Clear the cache for every generator execution.
Tasks
Definition of Done
Summary
Cache the results of
getRelativeImportSpecifier()so repeated file pair lookups reuse previously computed relative paths.Proposed Solution
Tasks
Definition of Done