From d76fdefd4dbcec01fdb88ac5a5759a8c6d69303b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 5 Oct 2022 15:46:36 -0700 Subject: [PATCH] Plugin probe location is higher priority than peer node_modules Fixes #34616 --- src/server/project.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/server/project.ts b/src/server/project.ts index e3dc2b77369d6..40dc531157413 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -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 | undefined): void { if (!this.projectService.globalPlugins.length) return; const host = this.projectService.host; @@ -1613,14 +1623,8 @@ namespace ts.server { return; } - // 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(), "../../.."), - ]; - // Enable global plugins with synthetic configuration entries + const searchPaths = this.getGlobalPluginSearchPaths(); for (const globalPluginName of this.projectService.globalPlugins) { // Skip empty names from odd commandline parses if (!globalPluginName) continue; @@ -2527,10 +2531,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`);