Skip to content

feat: Add option to disable ngcc #1620

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

Merged
merged 1 commit into from
Mar 29, 2022
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
5 changes: 5 additions & 0 deletions client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ function constructArgs(ctx: vscode.ExtensionContext, viewEngine: boolean): strin
args.push('--includeCompletionsWithSnippetText');
}

const disableNgcc = config.get<boolean>('angular.disableNgcc');
if (disableNgcc) {
args.push('--disableNgcc');
}

const tsdk: string|null = config.get('typescript.tsdk', null);
const tsProbeLocations = [tsdk, ...getProbeLocations(ctx.extensionPath)];
args.push('--tsProbeLocations', tsProbeLocations.join(','));
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@
"type": "boolean",
"default": true,
"markdownDescription": "Enable/disable snippet completions from Angular language server. Requires using TypeScript 4.3+ in the workspace and the `legacy View Engine` option to be disabled."
},
"angular.disableNgcc": {
"type": "boolean",
"default": false,
"markdownDescription": "Manually disable the step to run ngcc. [ngcc](https://github.com/angular/angular/blob/master/packages/compiler/design/architecture.md#high-level-proposal) is required to run and gather metadata from libraries not published with Ivy instructions. This can be run outside of VSCode instead (for example, as part of the build/rebuild in the CLI). Note that ngcc needs to run not only at startup, but also whenever the dependencies change. Failing to run ngcc when required can result in incomplete information and spurious errors reported by the language service."
}
}
},
Expand Down Expand Up @@ -223,4 +228,4 @@
"type": "git",
"url": "https://github.com/angular/vscode-ng-language-service"
}
}
}
5 changes: 5 additions & 0 deletions server/src/cmdline_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ interface CommandLineOptions {
* If true, use Ivy LS, otherwise use legacy View Engine LS.
*/
ivy: boolean;
/**
* If true, skips the running ngcc when using Ivy LS.
*/
disableNgcc: boolean;
logFile?: string;
logVerbosity?: string;
logToConsole: boolean;
Expand All @@ -45,6 +49,7 @@ export function parseCommandLine(argv: string[]): CommandLineOptions {
return {
help: hasArgument(argv, '--help'),
ivy: !hasArgument(argv, '--viewEngine'),
disableNgcc: hasArgument(argv, '--disableNgcc'),
logFile: findArgument(argv, '--logFile'),
logVerbosity: findArgument(argv, '--logVerbosity'),
logToConsole: hasArgument(argv, '--logToConsole'),
Expand Down
1 change: 1 addition & 0 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function main() {
ngPlugin: '@angular/language-service',
resolvedNgLsPath: ng.resolvedPath,
ivy: isG3 ? true : options.ivy,
disableNgcc: options.disableNgcc,
logToConsole: options.logToConsole,
includeAutomaticOptionalChainCompletions: options.includeAutomaticOptionalChainCompletions,
includeCompletionsWithSnippetText: options.includeCompletionsWithSnippetText,
Expand Down
5 changes: 4 additions & 1 deletion server/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface SessionOptions {
ngPlugin: string;
resolvedNgLsPath: string;
ivy: boolean;
disableNgcc: boolean;
logToConsole: boolean;
includeAutomaticOptionalChainCompletions: boolean;
includeCompletionsWithSnippetText: boolean;
Expand All @@ -51,6 +52,7 @@ export class Session {
private readonly projectService: ts.server.ProjectService;
private readonly logger: ts.server.Logger;
private readonly ivy: boolean;
private readonly disableNgcc: boolean;
private readonly configuredProjToExternalProj = new Map<string, string>();
private readonly logToConsole: boolean;
private readonly openFiles = new MruTracker();
Expand All @@ -77,6 +79,7 @@ export class Session {
this.includeCompletionsWithSnippetText = options.includeCompletionsWithSnippetText;
this.logger = options.logger;
this.ivy = options.ivy;
this.disableNgcc = options.disableNgcc;
this.logToConsole = options.logToConsole;
// Create a connection for the server. The connection uses Node's IPC as a transport.
this.connection = lsp.createConnection({
Expand Down Expand Up @@ -454,7 +457,7 @@ export class Session {
const {project} = event.data;
const angularCore = this.findAngularCore(project);
if (angularCore) {
if (this.ivy && isExternalAngularCore(angularCore)) {
if (this.ivy && isExternalAngularCore(angularCore) && !this.disableNgcc) {
// Do not wait on this promise otherwise we'll be blocking other requests
this.runNgcc(project);
} else {
Expand Down