Skip to content

Commit

Permalink
Merge pull request #15941 from RyanCavanaugh/release-2.3
Browse files Browse the repository at this point in the history
Port plugin load
  • Loading branch information
RyanCavanaugh committed May 18, 2017
2 parents 4dc00a2 + e01ea0e commit 367e072
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/server/editorServices.ts
Expand Up @@ -283,6 +283,7 @@ namespace ts.server {
throttleWaitMilliseconds?: number;
globalPlugins?: string[];
pluginProbeLocations?: string[];
allowLocalPluginLoads?: boolean;
}

export class ProjectService {
Expand Down Expand Up @@ -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;
Expand All @@ -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");

Expand Down
6 changes: 6 additions & 0 deletions src/server/project.ts
Expand Up @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions src/server/server.ts
Expand Up @@ -16,6 +16,7 @@ namespace ts.server {
telemetryEnabled: boolean;
globalPlugins: string[];
pluginProbeLocations: string[];
allowLocalPluginLoads: boolean;
}

const net: {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand All @@ -761,7 +764,8 @@ namespace ts.server {
telemetryEnabled,
logger,
globalPlugins,
pluginProbeLocations
pluginProbeLocations,
allowLocalPluginLoads
};

const ioSession = new IOSession(options);
Expand Down
4 changes: 3 additions & 1 deletion src/server/session.ts
Expand Up @@ -348,6 +348,7 @@ namespace ts.server {

globalPlugins?: string[];
pluginProbeLocations?: string[];
allowLocalPluginLoads?: boolean;
}

export class Session implements EventSender {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 367e072

Please sign in to comment.