From aafde79a71bd17e58f315772bb3fc04a5d8fdfa2 Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Fri, 15 Oct 2021 10:14:23 -0700 Subject: [PATCH] refactor(compiler-cli): throw an error when compiling with View Engine. (#43862) The View Engine compiler now throws when constructed and will be removed shortly. Direct users should switch to `NgtscProgram` to build with [Ivy](https://angular.io/guide/ivy). The View Engine compiler is being removed, so this makes it throw an error to ensure no one accidentally depends on code being removed. PR Close #43862 --- packages/compiler-cli/src/transformers/program.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/compiler-cli/src/transformers/program.ts b/packages/compiler-cli/src/transformers/program.ts index 6e17ff476f0..73d78fd820d 100644 --- a/packages/compiler-cli/src/transformers/program.ts +++ b/packages/compiler-cli/src/transformers/program.ts @@ -38,6 +38,12 @@ import {createMessageDiagnostic, DTS, GENERATED_FILES, isInRootDir, ngToTsDiagno */ const MAX_FILE_COUNT_FOR_SINGLE_FILE_EMIT = 20; +/** Error message to show when attempting to build View Engine. */ +const VE_DISABLED_MESSAGE = ` +This compilation is using the View Engine compiler which is no longer supported by the Angular team +and is being removed. Please upgrade to the Ivy compiler by switching to \`NgtscProgram\`. See +https://angular.io/guide/ivy for more information. +`.trim().split('\n').join(' '); /** * Fields to lower within metadata in render2 mode. @@ -110,6 +116,10 @@ class AngularCompilerProgram implements Program { constructor( rootNames: ReadonlyArray, private options: CompilerOptions, private host: CompilerHost, oldProgram?: Program) { + if (true as boolean) { + throw new Error(VE_DISABLED_MESSAGE); + } + this.rootNames = [...rootNames]; if (!options.disableTypeScriptVersionCheck) {