Merge pull request #15941 from RyanCavanaugh/release-2.3

Port plugin load
This commit is contained in:
Ryan Cavanaugh 2017-05-18 14:39:38 -07:00 committed by GitHub
commit 367e072f54
4 changed files with 18 additions and 3 deletions

View File

@ -283,6 +283,7 @@ namespace ts.server {
throttleWaitMilliseconds?: number;
globalPlugins?: string[];
pluginProbeLocations?: string[];
allowLocalPluginLoads?: boolean;
}
export class ProjectService {
@ -342,6 +343,7 @@ namespace ts.server {
public readonly globalPlugins: ReadonlyArray<string>;
public readonly pluginProbeLocations: ReadonlyArray<string>;
public readonly allowLocalPluginLoads: boolean;
constructor(opts: ProjectServiceOptions) {
this.host = opts.host;
@ -353,6 +355,7 @@ namespace ts.server {
this.eventHandler = opts.eventHandler;
this.globalPlugins = opts.globalPlugins || emptyArray;
this.pluginProbeLocations = opts.pluginProbeLocations || emptyArray;
this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads;
Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService");

View File

@ -873,6 +873,12 @@ namespace ts.server {
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
const searchPaths = [combinePaths(host.getExecutingFilePath(), "../../.."), ...this.projectService.pluginProbeLocations];
if (this.projectService.allowLocalPluginLoads) {
const local = getDirectoryPath(this.canonicalConfigFilePath);
this.projectService.logger.info(`Local plugin loading enabled; adding ${local} to search paths`);
searchPaths.unshift(local);
}
// Enable tsconfig-specified plugins
if (options.plugins) {
for (const pluginConfigEntry of options.plugins) {

View File

@ -16,6 +16,7 @@ namespace ts.server {
telemetryEnabled: boolean;
globalPlugins: string[];
pluginProbeLocations: string[];
allowLocalPluginLoads: boolean;
}
const net: {
@ -403,7 +404,8 @@ namespace ts.server {
logger,
canUseEvents,
globalPlugins: options.globalPlugins,
pluginProbeLocations: options.pluginProbeLocations});
pluginProbeLocations: options.pluginProbeLocations,
allowLocalPluginLoads: options.allowLocalPluginLoads });
if (telemetryEnabled && typingsInstaller) {
typingsInstaller.setTelemetrySender(this);
@ -744,6 +746,7 @@ namespace ts.server {
const globalPlugins = (findArgument("--globalPlugins") || "").split(",");
const pluginProbeLocations = (findArgument("--pluginProbeLocations") || "").split(",");
const allowLocalPluginLoads = hasArgument("--allowLocalPluginLoads");
const useSingleInferredProject = hasArgument("--useSingleInferredProject");
const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition");
@ -761,7 +764,8 @@ namespace ts.server {
telemetryEnabled,
logger,
globalPlugins,
pluginProbeLocations
pluginProbeLocations,
allowLocalPluginLoads
};
const ioSession = new IOSession(options);

View File

@ -348,6 +348,7 @@ namespace ts.server {
globalPlugins?: string[];
pluginProbeLocations?: string[];
allowLocalPluginLoads?: boolean;
}
export class Session implements EventSender {
@ -435,7 +436,8 @@ namespace ts.server {
throttleWaitMilliseconds,
eventHandler: this.eventHandler,
globalPlugins: opts.globalPlugins,
pluginProbeLocations: opts.pluginProbeLocations
pluginProbeLocations: opts.pluginProbeLocations,
allowLocalPluginLoads: opts.allowLocalPluginLoads
};
this.projectService = new ProjectService(settings);
this.gcTimer = new GcTimer(this.host, /*delay*/ 7000, this.logger);