@@ -906,7 +906,7 @@ namespace ts.server {
906906 return this . getFileNames ( ) . map ( ( fileName ) : protocol . FileWithProjectReferenceRedirectInfo => ( {
907907 fileName,
908908 isSourceOfProjectReferenceRedirect : includeProjectReferenceRedirectInfo && this . isSourceOfProjectReferenceRedirect ( fileName )
909- } ) ) ;
909+ } ) ) ;
910910 }
911911
912912 hasConfigFile ( configFilePath : NormalizedPath ) {
@@ -1482,7 +1482,7 @@ namespace ts.server {
14821482 if ( ! lastReportedFileNames . has ( fileName ) ) {
14831483 added . set ( fileName , isSourceOfProjectReferenceRedirect ) ;
14841484 }
1485- else if ( includeProjectReferenceRedirectInfo && isSourceOfProjectReferenceRedirect !== lastReportedFileNames . get ( fileName ) ) {
1485+ else if ( includeProjectReferenceRedirectInfo && isSourceOfProjectReferenceRedirect !== lastReportedFileNames . get ( fileName ) ) {
14861486 updatedRedirects . push ( {
14871487 fileName,
14881488 isSourceOfProjectReferenceRedirect
@@ -1555,9 +1555,9 @@ namespace ts.server {
15551555
15561556 // Search any globally-specified probe paths, then our peer node_modules
15571557 const searchPaths = [
1558- ...this . projectService . pluginProbeLocations ,
1559- // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
1560- combinePaths ( this . projectService . getExecutingFilePath ( ) , "../../.." ) ,
1558+ ...this . projectService . pluginProbeLocations ,
1559+ // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
1560+ combinePaths ( this . projectService . getExecutingFilePath ( ) , "../../.." ) ,
15611561 ] ;
15621562
15631563 if ( this . projectService . globalPlugins ) {
@@ -1577,7 +1577,7 @@ namespace ts.server {
15771577 }
15781578 }
15791579
1580- protected enablePlugin ( pluginConfigEntry : PluginImport , searchPaths : string [ ] , pluginConfigOverrides : Map < any > | undefined ) {
1580+ protected async enablePlugin ( pluginConfigEntry : PluginImport , searchPaths : string [ ] , pluginConfigOverrides : Map < any > | undefined ) {
15811581 this . projectService . logger . info ( `Enabling plugin ${ pluginConfigEntry . name } from candidate paths: ${ searchPaths . join ( "," ) } ` ) ;
15821582 if ( ! pluginConfigEntry . name || parsePackageName ( pluginConfigEntry . name ) . rest ) {
15831583 this . projectService . logger . info ( `Skipped loading plugin ${ pluginConfigEntry . name || JSON . stringify ( pluginConfigEntry ) } because only package name is allowed plugin name` ) ;
@@ -1589,8 +1589,27 @@ namespace ts.server {
15891589 const logError = ( message : string ) => {
15901590 ( errorLogs || ( errorLogs = [ ] ) ) . push ( message ) ;
15911591 } ;
1592- const resolvedModule = firstDefined ( searchPaths , searchPath =>
1593- Project . resolveModule ( pluginConfigEntry . name , searchPath , this . projectService . host , log , logError ) as PluginModuleFactory | undefined ) ;
1592+
1593+ let resolvedModule : any | undefined ;
1594+ if ( this . projectService . host . fetchServicePlugin ) {
1595+ for ( const searchPath of searchPaths ) {
1596+ try {
1597+ resolvedModule = await this . projectService . host . fetchServicePlugin ( searchPath , pluginConfigEntry . name ) ;
1598+ }
1599+ catch ( e ) {
1600+ // TODO: log this?
1601+ continue ;
1602+ }
1603+ if ( resolvedModule ) {
1604+ break ;
1605+ }
1606+ }
1607+ }
1608+ else {
1609+ resolvedModule = firstDefined ( searchPaths , searchPath =>
1610+ Project . resolveModule ( pluginConfigEntry . name , searchPath , this . projectService . host , log , logError ) as PluginModuleFactory | undefined ) ;
1611+ }
1612+
15941613 if ( resolvedModule ) {
15951614 const configurationOverride = pluginConfigOverrides && pluginConfigOverrides . get ( pluginConfigEntry . name ) ;
15961615 if ( configurationOverride ) {
0 commit comments