feat: make the Ivy compiler the default for ngc (#32219)

This commit switches the default value of the enableIvy flag to true.
Applications that run ngc will now by default receive an Ivy build!

This does not affect the way Bazel builds in the Angular repo work, since
those are still switched based on the value of the --define=compile flag.
Additionally, projects using @angular/bazel still use View Engine builds
by default.

Since most of the Angular repo tests are still written against View Engine
(particularly because we still publish VE packages to NPM), this switch
also requires lots of `enableIvy: false` flags in tsconfigs throughout the
repo.

Congrats to the team for reaching this milestone!

PR Close #32219
This commit is contained in:
Alex Rickabaugh
2019-08-20 10:52:31 -07:00
committed by Andrew Kushnir
parent 2b64031ddc
commit ec4381dd40
43 changed files with 146 additions and 48 deletions

View File

@ -68,7 +68,8 @@ export function mainDiagnosticsForTest(
}
function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback|undefined {
const transformDecorators = !options.enableIvy && options.annotationsAs !== 'decorators';
const transformDecorators =
(options.enableIvy === false && options.annotationsAs !== 'decorators');
const transformTypesToClosure = options.annotateForClosureCompiler;
if (!transformDecorators && !transformTypesToClosure) {
return undefined;
@ -205,7 +206,7 @@ function reportErrorsAndExit(
const errorsAndWarnings = filterErrorsAndWarnings(allDiagnostics);
if (errorsAndWarnings.length) {
const formatHost = getFormatDiagnosticsHost(options);
if (options && options.enableIvy === true) {
if (options && options.enableIvy !== false) {
const ngDiagnostics = errorsAndWarnings.filter(api.isNgDiagnostic);
const tsDiagnostics = errorsAndWarnings.filter(api.isTsDiagnostic);
consoleError(replaceTsWithNgInErrors(

View File

@ -186,10 +186,7 @@ export interface CompilerOptions extends ts.CompilerOptions {
/**
* Tells the compiler to generate definitions using the Render3 style code generation.
* This option defaults to `false`.
*
* Not all features are supported with this option enabled. It is only supported
* for experimentation and testing of Render3 style code generation.
* This option defaults to `true`.
*
* Acceptable values are as follows:
*

View File

@ -142,7 +142,7 @@ class AngularCompilerProgram implements Program {
}
this.loweringMetadataTransform =
new LowerMetadataTransform(options.enableIvy ? R3_LOWER_FIELDS : LOWER_FIELDS);
new LowerMetadataTransform(options.enableIvy !== false ? R3_LOWER_FIELDS : LOWER_FIELDS);
this.metadataCache = this.createMetadataCache([this.loweringMetadataTransform]);
}
@ -262,7 +262,7 @@ class AngularCompilerProgram implements Program {
emitCallback?: TsEmitCallback,
mergeEmitResultsCallback?: TsMergeEmitResultsCallback,
} = {}): ts.EmitResult {
if (this.options.enableIvy) {
if (this.options.enableIvy !== false) {
throw new Error('Cannot run legacy compiler in ngtsc mode');
}
return this._emitRender2(parameters);
@ -897,7 +897,7 @@ export function createProgram({rootNames, options, host, oldProgram}: {
options: CompilerOptions,
host: CompilerHost, oldProgram?: Program
}): Program {
if (options.enableIvy === true) {
if (options.enableIvy !== false) {
return new NgtscProgram(rootNames, options, host, oldProgram as NgtscProgram);
} else {
return new AngularCompilerProgram(rootNames, options, host, oldProgram);