@@ -198,13 +198,13 @@ namespace ts.server {
198198 return hasOneOrMoreJsAndNoTsFiles ( this ) ;
199199 }
200200
201- public static resolveModule ( moduleName : string , initialDir : string , host : ServerHost , log : ( message : string ) => void ) : { } | undefined {
201+ public static resolveModule ( moduleName : string , initialDir : string , host : ServerHost , log : ( message : string ) => void , logErrors ?: ( message : string ) => void ) : { } | undefined {
202202 const resolvedPath = normalizeSlashes ( host . resolvePath ( combinePaths ( initialDir , "node_modules" ) ) ) ;
203203 log ( `Loading ${ moduleName } from ${ initialDir } (resolved to ${ resolvedPath } )` ) ;
204204 const result = host . require ! ( resolvedPath , moduleName ) ; // TODO: GH#18217
205205 if ( result . error ) {
206206 const err = result . error . stack || result . error . message || JSON . stringify ( result . error ) ;
207- log ( `Failed to load module '${ moduleName } ': ${ err } ` ) ;
207+ ( logErrors || log ) ( `Failed to load module '${ moduleName } ' from ${ resolvedPath } : ${ err } ` ) ;
208208 return undefined ;
209209 }
210210 return result . module ;
@@ -1142,12 +1142,11 @@ namespace ts.server {
11421142 protected enablePlugin ( pluginConfigEntry : PluginImport , searchPaths : string [ ] , pluginConfigOverrides : Map < any > | undefined ) {
11431143 this . projectService . logger . info ( `Enabling plugin ${ pluginConfigEntry . name } from candidate paths: ${ searchPaths . join ( "," ) } ` ) ;
11441144
1145- const log = ( message : string ) => {
1146- this . projectService . logger . info ( message ) ;
1147- } ;
1148-
1145+ const log = ( message : string ) => this . projectService . logger . info ( message ) ;
1146+ let errorLogs : string [ ] | undefined ;
1147+ const logError = ( message : string ) => { ( errorLogs || ( errorLogs = [ ] ) ) . push ( message ) ; } ;
11491148 const resolvedModule = firstDefined ( searchPaths , searchPath =>
1150- < PluginModuleFactory | undefined > Project . resolveModule ( pluginConfigEntry . name , searchPath , this . projectService . host , log ) ) ;
1149+ < PluginModuleFactory | undefined > Project . resolveModule ( pluginConfigEntry . name , searchPath , this . projectService . host , log , logError ) ) ;
11511150 if ( resolvedModule ) {
11521151 const configurationOverride = pluginConfigOverrides && pluginConfigOverrides . get ( pluginConfigEntry . name ) ;
11531152 if ( configurationOverride ) {
@@ -1160,6 +1159,7 @@ namespace ts.server {
11601159 this . enableProxy ( resolvedModule , pluginConfigEntry ) ;
11611160 }
11621161 else {
1162+ forEach ( errorLogs , log ) ;
11631163 this . projectService . logger . info ( `Couldn't find ${ pluginConfigEntry . name } ` ) ;
11641164 }
11651165 }
0 commit comments