Cache specifier resolutions for speed when emitting many types from the same place (#25112)
* Cache specifier resolutions for speed when emitting many types from the same place * I swear I accepted this once already
This commit is contained in:
parent
38a60ac59b
commit
c441451f83
|
@ -4062,15 +4062,25 @@ namespace ts {
|
|||
// ambient module, just use declaration/symbol name (fallthrough)
|
||||
}
|
||||
else {
|
||||
if (file.moduleName) {
|
||||
return `"${file.moduleName}"`;
|
||||
}
|
||||
const contextFile = getSourceFileOfNode(getOriginalNode(context!.enclosingDeclaration))!;
|
||||
return `"${file.moduleName || moduleSpecifiers.getModuleSpecifiers(
|
||||
symbol,
|
||||
compilerOptions,
|
||||
contextFile,
|
||||
context!.tracker.moduleResolverHost!,
|
||||
context!.tracker.moduleResolverHost!.getSourceFiles!(),
|
||||
{ importModuleSpecifierPreference: "non-relative" }
|
||||
)[0]}"`;
|
||||
const links = getSymbolLinks(symbol);
|
||||
let specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
|
||||
if (!specifier) {
|
||||
specifier = flatten(moduleSpecifiers.getModuleSpecifiers(
|
||||
symbol,
|
||||
compilerOptions,
|
||||
contextFile,
|
||||
context!.tracker.moduleResolverHost!,
|
||||
context!.tracker.moduleResolverHost!.getSourceFiles!(),
|
||||
{ importModuleSpecifierPreference: "non-relative" }
|
||||
))[0];
|
||||
links.specifierCache = links.specifierCache || createMap();
|
||||
links.specifierCache.set(contextFile.path, specifier);
|
||||
}
|
||||
return `"${specifier}"`;
|
||||
}
|
||||
}
|
||||
const declaration = symbol.declarations[0];
|
||||
|
|
|
@ -3499,6 +3499,7 @@ namespace ts {
|
|||
enumKind?: EnumKind; // Enum declaration classification
|
||||
originatingImport?: ImportDeclaration | ImportCall; // Import declaration which produced the symbol, present if the symbol is marked as uncallable but had call signatures in `resolveESModuleSymbol`
|
||||
lateSymbol?: Symbol; // Late-bound symbol for a computed property
|
||||
specifierCache?: Map<string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
|
|
@ -3056,6 +3056,7 @@ declare namespace ts {
|
|||
enumKind?: EnumKind;
|
||||
originatingImport?: ImportDeclaration | ImportCall;
|
||||
lateSymbol?: Symbol;
|
||||
specifierCache?: Map<string>;
|
||||
}
|
||||
enum EnumKind {
|
||||
Numeric = 0,
|
||||
|
|
Loading…
Reference in a new issue