Skip to content

Commit

Permalink
Plugin probe location is higher priority than peer node_modules
Browse files Browse the repository at this point in the history
Fixes #34616
  • Loading branch information
sheetalkamat committed Oct 5, 2022
1 parent c18791c commit 8134936
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/server/project.ts
Expand Up @@ -1604,6 +1604,16 @@ namespace ts.server {
return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
}

/*@internal*/
protected getGlobalPluginSearchPaths() {
// Search any globally-specified probe paths, then our peer node_modules
return [
...this.projectService.pluginProbeLocations,
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
];
}

protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map<any> | undefined): void {
if (!this.projectService.globalPlugins.length) return;
const host = this.projectService.host;
Expand All @@ -1614,11 +1624,7 @@ namespace ts.server {
}

// Search any globally-specified probe paths, then our peer node_modules
const searchPaths = [
...this.projectService.pluginProbeLocations,
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
];
const searchPaths = this.getGlobalPluginSearchPaths();

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

// Search our peer node_modules, then any globally-specified probe paths
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
const searchPaths = [combinePaths(this.projectService.getExecutingFilePath(), "../../.."), ...this.projectService.pluginProbeLocations];

const searchPaths = this.getGlobalPluginSearchPaths();
if (this.projectService.allowLocalPluginLoads) {
const local = getDirectoryPath(this.canonicalConfigFilePath);
this.projectService.logger.info(`Local plugin loading enabled; adding ${local} to search paths`);
Expand Down

0 comments on commit 8134936

Please sign in to comment.