Skip to content

Commit d76fdef

Browse files
committed
Plugin probe location is higher priority than peer node_modules
Fixes #34616
1 parent c18791c commit d76fdef

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/server/project.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,16 @@ namespace ts.server {
16041604
return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
16051605
}
16061606

1607+
/*@internal*/
1608+
protected getGlobalPluginSearchPaths() {
1609+
// Search any globally-specified probe paths, then our peer node_modules
1610+
return [
1611+
...this.projectService.pluginProbeLocations,
1612+
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
1613+
combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
1614+
];
1615+
}
1616+
16071617
protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map<any> | undefined): void {
16081618
if (!this.projectService.globalPlugins.length) return;
16091619
const host = this.projectService.host;
@@ -1613,14 +1623,8 @@ namespace ts.server {
16131623
return;
16141624
}
16151625

1616-
// Search any globally-specified probe paths, then our peer node_modules
1617-
const searchPaths = [
1618-
...this.projectService.pluginProbeLocations,
1619-
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
1620-
combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
1621-
];
1622-
16231626
// Enable global plugins with synthetic configuration entries
1627+
const searchPaths = this.getGlobalPluginSearchPaths();
16241628
for (const globalPluginName of this.projectService.globalPlugins) {
16251629
// Skip empty names from odd commandline parses
16261630
if (!globalPluginName) continue;
@@ -2527,10 +2531,7 @@ namespace ts.server {
25272531
return;
25282532
}
25292533

2530-
// Search our peer node_modules, then any globally-specified probe paths
2531-
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
2532-
const searchPaths = [combinePaths(this.projectService.getExecutingFilePath(), "../../.."), ...this.projectService.pluginProbeLocations];
2533-
2534+
const searchPaths = this.getGlobalPluginSearchPaths();
25342535
if (this.projectService.allowLocalPluginLoads) {
25352536
const local = getDirectoryPath(this.canonicalConfigFilePath);
25362537
this.projectService.logger.info(`Local plugin loading enabled; adding ${local} to search paths`);

0 commit comments

Comments
 (0)