Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port plugin load #15941

Merged
merged 2 commits into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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