Skip to content

Commit 4d9ef09

Browse files
author
Keen Yee Liau
committed
fix: do not load plugins except @angular/language-service
Users can specify any arbitrary plugins in their `tsconfig.json`, and tsserver will load all of them by default. In Angular server, we do not want this behavior since other plugins can slow down the server considerably. Angular server should only load `@angular/language-service`. In google3, `@bazel/tsetse` and `ide_performance` plugins are automatically added by the `ts_config` rule.
1 parent 86f32d8 commit 4d9ef09

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

server/src/server_host.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,13 @@ export class ServerHost implements ts.server.ServerHost {
177177
return clearImmediate(timeoutId);
178178
}
179179

180-
require(initialPath: string, moduleName: string) {
180+
require(initialPath: string, moduleName: string): ts.server.RequireResult {
181+
if (moduleName !== '@angular/language-service') {
182+
return {
183+
module: undefined,
184+
error: new Error(`Angular server will not load plugin '${moduleName}'.`),
185+
};
186+
}
181187
try {
182188
let modulePath = require.resolve(moduleName, {
183189
paths: [initialPath],

server/src/session.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export class Session {
8989
eventHandler: (e) => this.handleProjectServiceEvent(e),
9090
globalPlugins: [options.ngPlugin],
9191
pluginProbeLocations: [options.resolvedNgLsPath],
92-
allowLocalPluginLoads: false, // do not load plugins from tsconfig.json
92+
// do not resolve plugins from the directory where tsconfig.json is located
93+
allowLocalPluginLoads: false,
9394
});
9495

9596
projSvc.setHostConfiguration({

0 commit comments

Comments
 (0)