Skip to content

Commit 8134936

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

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/server/project.ts

Lines changed: 12 additions & 9 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;
@@ -1614,11 +1624,7 @@ namespace ts.server {
16141624
}
16151625

16161626
// 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-
];
1627+
const searchPaths = this.getGlobalPluginSearchPaths();
16221628

16231629
// Enable global plugins with synthetic configuration entries
16241630
for (const globalPluginName of this.projectService.globalPlugins) {
@@ -2527,10 +2533,7 @@ namespace ts.server {
25272533
return;
25282534
}
25292535

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-
2536+
const searchPaths = this.getGlobalPluginSearchPaths();
25342537
if (this.projectService.allowLocalPluginLoads) {
25352538
const local = getDirectoryPath(this.canonicalConfigFilePath);
25362539
this.projectService.logger.info(`Local plugin loading enabled; adding ${local} to search paths`);

0 commit comments

Comments
 (0)