Signed-off-by: BoJiang <jiangbo91@huawei.com>
Change-Id: I87eef7daa836007a169a94914627e5a8288815fc
This commit is contained in:
BoJiang 2024-06-17 10:40:40 +08:00
parent c220935126
commit e187c10281
2 changed files with 7 additions and 7 deletions

View File

@ -631,8 +631,8 @@ export function collectFileToIgnoreDiagnostics(rootFileNames: string[]): void {
// In watch mode, the `beforeBuild` phase will clear the parent and children fields in the cache. For files that have
// not been modified, the information needs to be restored using the `resolvedModuleNames` variable.
if (process.env.watchMode === 'true') {
for (let file of Object.keys(resolvedModulesCache)) {
createOrUpdateCache(resolvedModulesCache[file], file);
for (let [file, resolvedModules] of resolvedModulesCache) {
createOrUpdateCache(resolvedModules, file);
}
}
@ -848,9 +848,9 @@ export const resolvedModulesCache: Map<string, ts.ResolvedModuleFull[]> = new Ma
export function resolveModuleNames(moduleNames: string[], containingFile: string): ts.ResolvedModuleFull[] {
startTimeStatisticsLocation(resolveModuleNamesTime);
const resolvedModules: ts.ResolvedModuleFull[] = [];
const cacheFileContent: ts.ResolvedModuleFull[] = resolvedModulesCache.get(path.resolve(containingFile));
if (![...shouldResolvedFiles].length || shouldResolvedFiles.has(path.resolve(containingFile)) ||
!(resolvedModulesCache[path.resolve(containingFile)] &&
resolvedModulesCache[path.resolve(containingFile)].length === moduleNames.length)) {
!(cacheFileContent && cacheFileContent.length === moduleNames.length)) {
for (const moduleName of moduleNames) {
const result = ts.resolveModuleName(moduleName, containingFile, compilerOptions, moduleResolutionHost);
if (result.resolvedModule) {
@ -948,12 +948,12 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string
if (!projectConfig.xtsMode) {
createOrUpdateCache(resolvedModules, path.resolve(containingFile));
}
resolvedModulesCache[path.resolve(containingFile)] = resolvedModules;
resolvedModulesCache.set(path.resolve(containingFile), resolvedModules);
stopTimeStatisticsLocation(resolveModuleNamesTime);
return resolvedModules;
}
stopTimeStatisticsLocation(resolveModuleNamesTime);
return resolvedModulesCache[path.resolve(containingFile)];
return resolvedModulesCache.get(path.resolve(containingFile));
}
export interface ResolveModuleInfo {

View File

@ -921,7 +921,7 @@ function getFileNamesForScanningWhitelist(resolvedModulesCache: Map<string, ts.R
}
keepFilesAndDependencies.add(filePath);
const resolvedModules = resolvedModulesCache[path.resolve(filePath)];
const resolvedModules = resolvedModulesCache.get(path.resolve(filePath));
if (!resolvedModules) {
continue;
}