File tree 4 files changed +18
-3
lines changed 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -283,6 +283,7 @@ namespace ts.server {
283
283
throttleWaitMilliseconds ?: number ;
284
284
globalPlugins ?: string [ ] ;
285
285
pluginProbeLocations ?: string [ ] ;
286
+ allowLocalPluginLoads ?: boolean ;
286
287
}
287
288
288
289
export class ProjectService {
@@ -342,6 +343,7 @@ namespace ts.server {
342
343
343
344
public readonly globalPlugins : ReadonlyArray < string > ;
344
345
public readonly pluginProbeLocations : ReadonlyArray < string > ;
346
+ public readonly allowLocalPluginLoads : boolean ;
345
347
346
348
constructor ( opts : ProjectServiceOptions ) {
347
349
this . host = opts . host ;
@@ -353,6 +355,7 @@ namespace ts.server {
353
355
this . eventHandler = opts . eventHandler ;
354
356
this . globalPlugins = opts . globalPlugins || emptyArray ;
355
357
this . pluginProbeLocations = opts . pluginProbeLocations || emptyArray ;
358
+ this . allowLocalPluginLoads = ! ! opts . allowLocalPluginLoads ;
356
359
357
360
Debug . assert ( ! ! this . host . createHash , "'ServerHost.createHash' is required for ProjectService" ) ;
358
361
Original file line number Diff line number Diff line change @@ -873,6 +873,12 @@ namespace ts.server {
873
873
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
874
874
const searchPaths = [ combinePaths ( host . getExecutingFilePath ( ) , "../../.." ) , ...this . projectService . pluginProbeLocations ] ;
875
875
876
+ if ( this . projectService . allowLocalPluginLoads ) {
877
+ const local = getDirectoryPath ( this . canonicalConfigFilePath ) ;
878
+ this . projectService . logger . info ( `Local plugin loading enabled; adding ${ local } to search paths` ) ;
879
+ searchPaths . unshift ( local ) ;
880
+ }
881
+
876
882
// Enable tsconfig-specified plugins
877
883
if ( options . plugins ) {
878
884
for ( const pluginConfigEntry of options . plugins ) {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ namespace ts.server {
16
16
telemetryEnabled : boolean ;
17
17
globalPlugins : string [ ] ;
18
18
pluginProbeLocations : string [ ] ;
19
+ allowLocalPluginLoads : boolean ;
19
20
}
20
21
21
22
const net : {
@@ -403,7 +404,8 @@ namespace ts.server {
403
404
logger,
404
405
canUseEvents,
405
406
globalPlugins : options . globalPlugins ,
406
- pluginProbeLocations : options . pluginProbeLocations } ) ;
407
+ pluginProbeLocations : options . pluginProbeLocations ,
408
+ allowLocalPluginLoads : options . allowLocalPluginLoads } ) ;
407
409
408
410
if ( telemetryEnabled && typingsInstaller ) {
409
411
typingsInstaller . setTelemetrySender ( this ) ;
@@ -744,6 +746,7 @@ namespace ts.server {
744
746
745
747
const globalPlugins = ( findArgument ( "--globalPlugins" ) || "" ) . split ( "," ) ;
746
748
const pluginProbeLocations = ( findArgument ( "--pluginProbeLocations" ) || "" ) . split ( "," ) ;
749
+ const allowLocalPluginLoads = hasArgument ( "--allowLocalPluginLoads" ) ;
747
750
748
751
const useSingleInferredProject = hasArgument ( "--useSingleInferredProject" ) ;
749
752
const disableAutomaticTypingAcquisition = hasArgument ( "--disableAutomaticTypingAcquisition" ) ;
@@ -761,7 +764,8 @@ namespace ts.server {
761
764
telemetryEnabled,
762
765
logger,
763
766
globalPlugins,
764
- pluginProbeLocations
767
+ pluginProbeLocations,
768
+ allowLocalPluginLoads
765
769
} ;
766
770
767
771
const ioSession = new IOSession ( options ) ;
Original file line number Diff line number Diff line change @@ -348,6 +348,7 @@ namespace ts.server {
348
348
349
349
globalPlugins ?: string [ ] ;
350
350
pluginProbeLocations ?: string [ ] ;
351
+ allowLocalPluginLoads ?: boolean ;
351
352
}
352
353
353
354
export class Session implements EventSender {
@@ -401,7 +402,8 @@ namespace ts.server {
401
402
throttleWaitMilliseconds,
402
403
eventHandler : this . eventHandler ,
403
404
globalPlugins : opts . globalPlugins ,
404
- pluginProbeLocations : opts . pluginProbeLocations
405
+ pluginProbeLocations : opts . pluginProbeLocations ,
406
+ allowLocalPluginLoads : opts . allowLocalPluginLoads
405
407
} ;
406
408
this . projectService = new ProjectService ( settings ) ;
407
409
this . gcTimer = new GcTimer ( this . host , /*delay*/ 7000 , this . logger ) ;
You can’t perform that action at this time.
0 commit comments