Skip to content

Commit b866d6d

Browse files
committed
fix: Prevent legacy VE from being used with v13 projects (#1575)
Angular v13+ projects do not support VE. If the client detects a v13+ project in the workspace, it now sets legacy VE to false, regardless of the extension options or incompatible legacy projects in the workspace. (cherry picked from commit 2deee18)
1 parent 7ebb9a4 commit b866d6d

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

client/src/client.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,20 @@ function getServerOptions(ctx: vscode.ExtensionContext, debug: boolean): lsp.Nod
475475
// will return false even when the value is not set. If value is false, then
476476
// we need to check if all projects support Ivy language service.
477477
const config = vscode.workspace.getConfiguration();
478-
const viewEngine: boolean = config.get('angular.view-engine') || !allProjectsSupportIvy();
478+
let viewEngine: boolean = config.get('angular.view-engine') || !allProjectsSupportIvy();
479+
if (viewEngine && !allProjectsSupportVE()) {
480+
viewEngine = false;
481+
if (config.get('angular.view-engine')) {
482+
vscode.window.showErrorMessage(
483+
`The legacy View Engine option is enabled but the workspace contains a version 13 Angular project.` +
484+
` Legacy View Engine will be disabled since support for it was dropped in v13.`,
485+
);
486+
} else if (!allProjectsSupportIvy() && !allProjectsSupportVE()) {
487+
vscode.window.showErrorMessage(
488+
`The workspace contains a project that does not support legacy View Engine (Angular v13+) and a project that does not support the new current runtime (v8 and below).` +
489+
`The extension will not work for the legacy project in this workspace.`);
490+
}
491+
}
479492

480493
// Node module for the language server
481494
const args = constructArgs(ctx, viewEngine);
@@ -521,4 +534,15 @@ function allProjectsSupportIvy() {
521534
}
522535
}
523536
return true;
537+
}
538+
539+
function allProjectsSupportVE() {
540+
const workspaceFolders = vscode.workspace.workspaceFolders || [];
541+
for (const workspaceFolder of workspaceFolders) {
542+
const angularCore = resolve('@angular/core', workspaceFolder.uri.fsPath);
543+
if (angularCore?.version.greaterThanOrEqual(new Version('13')) === true) {
544+
return false;
545+
}
546+
}
547+
return true;
524548
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"angular.view-engine": {
9797
"type": "boolean",
9898
"default": false,
99-
"description": "Use legacy View Engine language service."
99+
"description": "Use legacy View Engine language service. This option is incompatible with projects using Angular v13 and above."
100100
},
101101
"angular.enable-strict-mode-prompt": {
102102
"type": "boolean",
@@ -216,4 +216,4 @@
216216
"type": "git",
217217
"url": "https://github.com/angular/vscode-ng-language-service"
218218
}
219-
}
219+
}

0 commit comments

Comments
 (0)