Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
31009c8
Write log about unresolved imports calculation
sheetalkamat Oct 17, 2023
d81f147
Add test when type acquisition changes
sheetalkamat Nov 7, 2023
592bba4
Verify getUnresolvedImports incrementally
sheetalkamat Oct 20, 2023
cae589d
Handle unnecessary typings request force just because root files change
sheetalkamat Oct 11, 2023
3ae4463
When type acquisition is disabled, remove the typing files set as root
sheetalkamat Oct 11, 2023
e89404f
Close watchers for TI that are no longer needed
sheetalkamat Oct 11, 2023
d839cae
Update the unresolved import list only if it will be used
sheetalkamat Oct 11, 2023
457d9b7
Do not update typings for project if type aquisition is disabled
sheetalkamat Oct 12, 2023
f659bec
If typing installer is disabled invalidate all the resolutions from t…
sheetalkamat Oct 12, 2023
1637783
Use globalCacheResolution to invalidate resolutions on typings update
sheetalkamat Oct 17, 2023
dad8851
Update cached import list update as part of resolving modules instead…
sheetalkamat Oct 20, 2023
cbbbf4a
If the there is no change detected in module resolution we shouldnt n…
sheetalkamat Oct 20, 2023
8e23cb4
Now that work with unresolved imports cleanup is done, remove the tem…
sheetalkamat Nov 9, 2023
2a08064
unresolved imports of empty array and undefined are same
sheetalkamat Nov 9, 2023
c9dcebe
Tests
sheetalkamat Jul 15, 2024
2f52238
Add incremental test where cache should have same resolutions as what…
sheetalkamat Sep 27, 2023
3b993ff
Make sure reused resolutions from file are accounted if all resolutio…
sheetalkamat Sep 29, 2023
254139c
In preparation of sharing resolutions, watch the resolutions right aw…
sheetalkamat Jul 11, 2023
a51e79a
Resolutions in cache stays for lifetime..
sheetalkamat Jul 8, 2024
b3ab401
Handle package json lifetime
sheetalkamat Jul 26, 2024
fb623b9
The redirected reference use that projects tsconfig directory as the …
sheetalkamat Jul 10, 2024
0633e0e
Dont pollute resolution so we can reuse it across projects
sheetalkamat Jul 19, 2024
ee741df
Factor out cache to be shared and not shared. Projects still are not …
sheetalkamat May 16, 2025
80ba295
Real sharing across projects
sheetalkamat Sep 27, 2024
69c37d3
Test cases for shared resolutions and effective type roots calculation
sheetalkamat Oct 2, 2024
ea2352a
Handle effective type roots and type ref resolution sharing cache
sheetalkamat Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
In preparation of sharing resolutions, watch the resolutions right aw…
…ay instead of defering external module reoslutions to watch all failed lookup locations
  • Loading branch information
sheetalkamat committed May 16, 2025
commit 254139c45f26e94efee052f81d94679a8c18acde
158 changes: 68 additions & 90 deletions src/compiler/resolutionCache.ts

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions src/harness/incrementalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ export function verifyResolutionCache(
path,
resolutions,
getResolvedModuleFileName,
/*deferWatchingNonRelativeResolution*/ true,
expected.resolvedModuleNames,
(name, mode) => actualProgram.getResolvedModule(actualProgram.getSourceFileByPath(path)!, name, mode),
)
Expand All @@ -238,7 +237,6 @@ export function verifyResolutionCache(
path,
resolutions,
getResolvedTypeRefFileName,
/*deferWatchingNonRelativeResolution*/ false,
expected.resolvedTypeReferenceDirectives,
(name, mode) =>
path !== inferredTypesPath ?
Expand All @@ -256,7 +254,6 @@ export function verifyResolutionCache(
getResolvedModuleFileName(resolved),
ts.getLibraryNameFromLibFileName(libFileName),
/*mode*/ undefined,
/*deferWatchingNonRelativeResolution*/ false,
);
expected.resolvedLibraries.set(libFileName, expectedResolution);
});
Expand Down Expand Up @@ -309,7 +306,20 @@ export function verifyResolutionCache(
!resolution.isInvalidated,
`${projectName}:: Resolution should not be invalidated`,
);
verifySet(resolutionToExpected.get(resolution)!.files, resolution.files, `${projectName}:: Resolution files`);
const expected = resolutionToExpected.get(resolution)!;
verifySet(expected.files, resolution.files, `${projectName}:: Resolution files`);
ts.Debug.assert(
expected.watchedFailed === resolution.watchedFailed,
`${projectName}:: Expected watchedFailed of Resolution ${expected.watchedFailed} but got ${resolution.watchedFailed}`,
);
ts.Debug.assert(
expected.watchedAffected === resolution.watchedAffected,
`${projectName}:: Expected watchedAffected of Resolution ${expected.watchedAffected} but got ${resolution.watchedAffected}`,
);
ts.Debug.assert(
expected.setAtRoot === resolution.setAtRoot,
`${projectName}:: Expected setAtRoot of Resolution ${expected.setAtRoot} but got ${resolution.setAtRoot}`,
);
});
verifyMapOfResolutionSet(expected.resolvedFileToResolution, actual.resolvedFileToResolution, `resolvedFileToResolution`);
verifyResolutionSet(expected.resolutionsWithFailedLookups, actual.resolutionsWithFailedLookups, `resolutionsWithFailedLookups`);
Expand Down Expand Up @@ -373,7 +383,6 @@ export function verifyResolutionCache(
fileName: ts.Path,
cache: ts.ModeAwareCache<T> | undefined,
getResolvedFileName: (resolution: T) => string | undefined,
deferWatchingNonRelativeResolution: boolean,
storeExpected: Map<ts.Path, ts.ModeAwareCache<ts.ResolutionWithFailedLookupLocations>>,
getProgramResolutions: (name: string, mode: ts.ResolutionMode) => T | undefined,
) {
Expand All @@ -384,7 +393,7 @@ export function verifyResolutionCache(
let expectedCache: ts.ModeAwareCache<ts.ResolutionWithFailedLookupLocations> | undefined;
cache?.forEach((resolved, name, mode) => {
const resolvedFileName = getResolvedFileName(resolved);
const expected = collectResolution(cacheType, fileName, resolved, resolvedFileName, name, mode, deferWatchingNonRelativeResolution);
const expected = collectResolution(cacheType, fileName, resolved, resolvedFileName, name, mode);
if (!expectedCache) storeExpected.set(fileName, expectedCache = ts.createModeAwareCache());
expectedCache.set(name, mode, expected);
// Resolution in cache should be same as that is in program
Expand All @@ -402,7 +411,6 @@ export function verifyResolutionCache(
resolvedFileName: string | undefined,
name: string,
mode: ts.ResolutionMode,
deferWatchingNonRelativeResolution: boolean,
): ExpectedResolution {
const existing = resolutionToRefs.get(resolved);
let expectedResolution: ExpectedResolution;
Expand All @@ -423,7 +431,7 @@ export function verifyResolutionCache(
expectedToResolution.set(expectedResolution, resolved);
resolutionToExpected.set(resolved, expectedResolution);
}
expected.watchFailedLookupLocationsOfExternalModuleResolutions(name, expectedResolution, fileName, () => ({ resolvedFileName }), deferWatchingNonRelativeResolution);
expected.watchResolution(expectedResolution, fileName, () => ({ resolvedFileName }));
return expectedResolution;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not
File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result.
Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'.
======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ========
FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2/other/sometype2/index.d.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file
FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/lib.d.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/other 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/other 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations
Expand All @@ -143,6 +141,8 @@ DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/configs 1 {"excludeFile
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/configs 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations
FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2/other/sometype2/index.d.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file
FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/lib.d.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file
../../tslibs/TS/Lib/lib.d.ts
Default library for target 'es5'
types/sometype.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ File '/home/src/projects/project/node_modules/foo/package.json' exists according
File '/home/src/projects/project/node_modules/foo/index.d.ts' exists - use it as a name resolution result.
Resolving real path for '/home/src/projects/project/node_modules/foo/index.mjs', result '/home/src/projects/project/node_modules/foo/index.mjs'.
======== Module name 'foo' was successfully resolved to '/home/src/projects/project/node_modules/foo/index.mjs' with Package ID 'foo/index.mjs@1.0.0'. ========
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects 0 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects 0 undefined Failed Lookup Locations
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules 1 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules 1 undefined Failed Lookup Locations
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project 0 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project 0 undefined Failed Lookup Locations
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/foo/package.json 2000 undefined File location affecting resolution
======== Resolving module 'bar' from '/home/src/projects/project/index.mts'. ========
Explicitly specified module resolution kind: 'Node16'.
Resolving in ESM mode with conditions 'import', 'types', 'node'.
Expand Down Expand Up @@ -285,6 +294,8 @@ File '/home/src/projects/project/node_modules/@types/bar/index.d.ts' exists - us
'package.json' does not have a 'peerDependencies' field.
Resolving real path for '/home/src/projects/project/node_modules/bar/index.mjs', result '/home/src/projects/project/node_modules/bar/index.mjs'.
======== Module name 'bar' was successfully resolved to '/home/src/projects/project/node_modules/bar/index.mjs' with Package ID 'bar/index.mjs@1.0.0'. ========
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/bar/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/@types/bar/package.json 2000 undefined File location affecting resolution
======== Resolving module 'foo2' from '/home/src/projects/project/index.mts'. ========
Explicitly specified module resolution kind: 'Node16'.
Resolving in ESM mode with conditions 'import', 'types', 'node'.
Expand All @@ -305,6 +316,7 @@ Resolved under condition 'types'.
Exiting conditional exports.
Resolving real path for '/home/src/projects/project/node_modules/foo2/index.d.ts', result '/home/src/projects/project/node_modules/foo2/index.d.ts'.
======== Module name 'foo2' was successfully resolved to '/home/src/projects/project/node_modules/foo2/index.d.ts' with Package ID 'foo2/index.d.ts@1.0.0'. ========
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/foo2/package.json 2000 undefined File location affecting resolution
======== Resolving module 'bar2' from '/home/src/projects/project/index.mts'. ========
Explicitly specified module resolution kind: 'Node16'.
Resolving in ESM mode with conditions 'import', 'types', 'node'.
Expand Down Expand Up @@ -335,6 +347,8 @@ Resolved under condition 'types'.
Exiting conditional exports.
Resolving real path for '/home/src/projects/project/node_modules/@types/bar2/index.d.ts', result '/home/src/projects/project/node_modules/@types/bar2/index.d.ts'.
======== Module name 'bar2' was successfully resolved to '/home/src/projects/project/node_modules/@types/bar2/index.d.ts' with Package ID '@types/bar2/index.d.ts@1.0.0'. ========
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/bar2/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/@types/bar2/package.json 2000 undefined File location affecting resolution
File '/home/src/projects/project/node_modules/foo2/package.json' exists according to earlier cached lookups.
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/foo2/index.d.ts 250 undefined Source file
File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists according to earlier cached lookups.
Expand All @@ -346,20 +360,6 @@ File '/home/src/package.json' does not exist according to earlier cached lookups
File '/home/package.json' does not exist according to earlier cached lookups.
File '/package.json' does not exist according to earlier cached lookups.
FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/lib.d.ts 250 undefined Source file
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects 0 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects 0 undefined Failed Lookup Locations
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules 1 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules 1 undefined Failed Lookup Locations
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project 0 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project 0 undefined Failed Lookup Locations
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/foo/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/bar/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/@types/bar/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/foo2/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/bar2/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/@types/bar2/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/package.json 2000 undefined File location affecting resolution
FileWatcher:: Added:: WatchInfo: /home/src/tslibs/package.json 2000 undefined File location affecting resolution
Expand Down Expand Up @@ -1952,6 +1952,8 @@ File '/home/src/projects/project/node_modules/@types/bar2/index.d.ts' exists - u
'package.json' does not have a 'peerDependencies' field.
Resolving real path for '/home/src/projects/project/node_modules/bar2/index.mjs', result '/home/src/projects/project/node_modules/bar2/index.mjs'.
======== Module name 'bar2' was successfully resolved to '/home/src/projects/project/node_modules/bar2/index.mjs' with Package ID 'bar2/index.mjs@1.0.0'. ========
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations
File '/home/src/projects/project/node_modules/foo/package.json' exists according to earlier cached lookups.
File '/home/src/projects/project/node_modules/@types/bar/package.json' exists according to earlier cached lookups.
File '/home/src/projects/project/node_modules/foo2/package.json' exists according to earlier cached lookups.
Expand All @@ -1962,8 +1964,6 @@ File '/home/src/package.json' does not exist according to earlier cached lookups
File '/home/package.json' does not exist according to earlier cached lookups.
File '/package.json' does not exist according to earlier cached lookups.
FileWatcher:: Close:: WatchInfo: /home/src/projects/project/node_modules/@types/bar2/index.d.ts 250 undefined Source file
DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations
tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'.

2 "compilerOptions": {
Expand Down
Loading