File tree Expand file tree Collapse file tree
packages/typescript/lib/node Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,6 +57,15 @@ export function decorateLanguageServiceHost(
5757 languageServiceHost . getCompilationSettings ( ) ,
5858 ) ;
5959
60+ let moduleResolutionProjectVersion : string | undefined ;
61+ const tryClearModuleResolutionCache = ( ) => {
62+ const projectVersion = languageServiceHost . getProjectVersion ?.( ) ;
63+ if ( projectVersion === undefined || projectVersion !== moduleResolutionProjectVersion ) {
64+ moduleResolutionCache . clear ( ) ;
65+ moduleResolutionProjectVersion = projectVersion ;
66+ }
67+ } ;
68+
6069 if ( resolveModuleNameLiterals ) {
6170 languageServiceHost . resolveModuleNameLiterals = (
6271 moduleLiterals ,
@@ -75,6 +84,7 @@ export function decorateLanguageServiceHost(
7584 options ,
7685 ) ;
7786 try {
87+ tryClearModuleResolutionCache ( ) ;
7888 if ( moduleLiterals . every ( name => ! pluginExtensions . some ( ext => name . text . endsWith ( ext ) ) ) ) {
7989 return resolveModuleNameLiterals (
8090 moduleLiterals ,
@@ -111,6 +121,7 @@ export function decorateLanguageServiceHost(
111121 options ,
112122 containingSourceFile ,
113123 ) => {
124+ tryClearModuleResolutionCache ( ) ;
114125 if ( moduleNames . every ( name => ! pluginExtensions . some ( ext => name . endsWith ( ext ) ) ) ) {
115126 return resolveModuleNames (
116127 moduleNames ,
You can’t perform that action at this time.
0 commit comments