@@ -198,13 +198,13 @@ namespace ts.server {
198
198
return hasOneOrMoreJsAndNoTsFiles ( this ) ;
199
199
}
200
200
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 {
202
202
const resolvedPath = normalizeSlashes ( host . resolvePath ( combinePaths ( initialDir , "node_modules" ) ) ) ;
203
203
log ( `Loading ${ moduleName } from ${ initialDir } (resolved to ${ resolvedPath } )` ) ;
204
204
const result = host . require ! ( resolvedPath , moduleName ) ; // TODO: GH#18217
205
205
if ( result . error ) {
206
206
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 } ` ) ;
208
208
return undefined ;
209
209
}
210
210
return result . module ;
@@ -1142,12 +1142,11 @@ namespace ts.server {
1142
1142
protected enablePlugin ( pluginConfigEntry : PluginImport , searchPaths : string [ ] , pluginConfigOverrides : Map < any > | undefined ) {
1143
1143
this . projectService . logger . info ( `Enabling plugin ${ pluginConfigEntry . name } from candidate paths: ${ searchPaths . join ( "," ) } ` ) ;
1144
1144
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 ) ; } ;
1149
1148
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 ) ) ;
1151
1150
if ( resolvedModule ) {
1152
1151
const configurationOverride = pluginConfigOverrides && pluginConfigOverrides . get ( pluginConfigEntry . name ) ;
1153
1152
if ( configurationOverride ) {
@@ -1160,6 +1159,7 @@ namespace ts.server {
1160
1159
this . enableProxy ( resolvedModule , pluginConfigEntry ) ;
1161
1160
}
1162
1161
else {
1162
+ forEach ( errorLogs , log ) ;
1163
1163
this . projectService . logger . info ( `Couldn't find ${ pluginConfigEntry . name } ` ) ;
1164
1164
}
1165
1165
}
0 commit comments