Skip to content

Commit 5f3e6cc

Browse files
authoredOct 6, 2022
Plugin probe location is higher priority than peer node_modules (#51079)
Fixes #34616
1 parent 2648f6a commit 5f3e6cc

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed
 

‎src/server/project.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,16 @@ namespace ts.server {
16061606
return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
16071607
}
16081608

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

1618-
// Search any globally-specified probe paths, then our peer node_modules
1619-
const searchPaths = [
1620-
...this.projectService.pluginProbeLocations,
1621-
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
1622-
combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
1623-
];
1624-
16251628
// Enable global plugins with synthetic configuration entries
1629+
const searchPaths = this.getGlobalPluginSearchPaths();
16261630
for (const globalPluginName of this.projectService.globalPlugins) {
16271631
// Skip empty names from odd commandline parses
16281632
if (!globalPluginName) continue;
@@ -2530,10 +2534,7 @@ namespace ts.server {
25302534
return;
25312535
}
25322536

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

0 commit comments

Comments
 (0)