From d31364c09c95abf23075be2df67c65c5e59e0ff9 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 13 Apr 2017 16:02:24 -0700 Subject: [PATCH] Load global plugins even if no local ones exist --- src/server/project.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/server/project.ts b/src/server/project.ts index 83b65f880e7..b92e8e84972 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -864,12 +864,6 @@ namespace ts.server { const host = this.projectService.host; const options = this.getCompilerOptions(); - if (!(options.plugins && options.plugins.length)) { - this.projectService.logger.info("No plugins exist"); - // No plugins - return; - } - if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); return; @@ -880,16 +874,21 @@ namespace ts.server { const searchPaths = [combinePaths(host.getExecutingFilePath(), "../../.."), ...this.projectService.pluginProbeLocations]; // Enable tsconfig-specified plugins - for (const pluginConfigEntry of options.plugins) { - this.enablePlugin(pluginConfigEntry, searchPaths); + if (options.plugins) { + for (const pluginConfigEntry of options.plugins) { + this.enablePlugin(pluginConfigEntry, searchPaths); + } } - // Enable global plugins with synthetic configuration entries - for (const globalPluginName of this.projectService.globalPlugins) { - // Skip already-locally-loaded plugins - if (options.plugins.some(p => p.name === globalPluginName)) continue; - - // Provide global: true so plugins can detect why they can't find their config - this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths); + + if (this.projectService.globalPlugins) { + // Enable global plugins with synthetic configuration entries + for (const globalPluginName of this.projectService.globalPlugins) { + // Skip already-locally-loaded plugins + if (options.plugins && options.plugins.some(p => p.name === globalPluginName)) continue; + + // Provide global: true so plugins can detect why they can't find their config + this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths); + } } }