@@ -14,6 +14,7 @@ import * as lsp from 'vscode-languageclient/node';
14
14
import { ProjectLoadingFinish , ProjectLoadingStart , SuggestStrictMode , SuggestStrictModeParams } from '../common/notifications' ;
15
15
import { NgccProgress , NgccProgressToken , NgccProgressType } from '../common/progress' ;
16
16
import { GetComponentsWithTemplateFile , GetTcbRequest , IsInAngularProject } from '../common/requests' ;
17
+ import { resolve , Version } from '../common/resolver' ;
17
18
18
19
import { isInsideComponentDecorator , isInsideInlineTemplateRegion } from './embedded_support' ;
19
20
import { ProgressReporter } from './progress-reporter' ;
@@ -388,7 +389,7 @@ function constructArgs(ctx: vscode.ExtensionContext): string[] {
388
389
const ngProbeLocations = getProbeLocations ( ngdk , ctx . extensionPath ) ;
389
390
args . push ( '--ngProbeLocations' , ngProbeLocations . join ( ',' ) ) ;
390
391
391
- const viewEngine : boolean = config . get ( 'angular.view-engine' , false ) ;
392
+ const viewEngine : boolean = config . get ( 'angular.view-engine' , ! allProjectsSupportIvy ( ) ) ;
392
393
if ( viewEngine ) {
393
394
args . push ( '--viewEngine' ) ;
394
395
}
@@ -432,4 +433,19 @@ function getServerOptions(ctx: vscode.ExtensionContext, debug: boolean): lsp.Nod
432
433
execArgv : debug ? devExecArgv : prodExecArgv ,
433
434
} ,
434
435
} ;
435
- }
436
+ }
437
+
438
+ /**
439
+ * Returns true if all projects in the workspace support Ivy LS, otherwise
440
+ * return false.
441
+ */
442
+ function allProjectsSupportIvy ( ) {
443
+ const workspaceFolders = vscode . workspace . workspaceFolders || [ ] ;
444
+ for ( const workspaceFolder of workspaceFolders ) {
445
+ const angularCore = resolve ( '@angular/core' , workspaceFolder . uri . fsPath ) ;
446
+ if ( angularCore ?. version . greaterThanOrEqual ( new Version ( '9' ) ) === false ) {
447
+ return false ;
448
+ }
449
+ }
450
+ return true ;
451
+ }
0 commit comments