From ddf7970b7883ce7bfcd58b9b2324eb7bf1664460 Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Mon, 22 Feb 2021 13:21:46 -0800 Subject: [PATCH] refactor(compiler-cli): separate out constant target of g3 patch (#40950) This commit moves a constant which is affected by a g3 sync patch into a separate file. This way, changes to the rest of the compiler codebase have no chance of conflicting with the patched code. PR Close #40950 --- .../compiler-cli/src/ngtsc/core/src/compiler.ts | 7 +++---- .../compiler-cli/src/ngtsc/core/src/config.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 packages/compiler-cli/src/ngtsc/core/src/config.ts diff --git a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts index f2b4a8e7b4..83e2e61e81 100644 --- a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts +++ b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts @@ -33,6 +33,8 @@ import {OptimizeFor, TemplateTypeChecker, TypeCheckingConfig, TypeCheckingProgra import {getSourceFileOrNull, isDtsPath, resolveModuleName} from '../../util/src/typescript'; import {LazyRoute, NgCompilerAdapter, NgCompilerOptions} from '../api'; +import {compileUndecoratedClassesWithAngularFeatures} from './config'; + /** * State information about a compilation which is only generated once some data is requested from * the `NgCompiler` (for example, by calling `getDiagnostics`). @@ -1012,10 +1014,7 @@ export class NgCompiler { new DirectiveDecoratorHandler( reflector, evaluator, metaRegistry, scopeRegistry, metaReader, defaultImportTracker, injectableRegistry, isCore, this.closureCompilerEnabled, - // In ngtsc we no longer want to compile undecorated classes with Angular features. - // Migrations for these patterns ran as part of `ng update` and we want to ensure - // that projects do not regress. See https://hackmd.io/@alx/ryfYYuvzH for more details. - /* compileUndecoratedClassesWithAngularFeatures */ false + compileUndecoratedClassesWithAngularFeatures, ) as Readonly>, // clang-format on // Pipe handler must be before injectable handler in list so pipe factories are printed diff --git a/packages/compiler-cli/src/ngtsc/core/src/config.ts b/packages/compiler-cli/src/ngtsc/core/src/config.ts new file mode 100644 index 0000000000..e59c7c80ac --- /dev/null +++ b/packages/compiler-cli/src/ngtsc/core/src/config.ts @@ -0,0 +1,16 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +// This file exists as a target for g3 patches which change the Angular compiler's behavior. +// Separating the patched code in a separate file eliminates the possibility of conflicts with the +// patch diffs when making changes to the rest of the compiler codebase. + +// In ngtsc we no longer want to compile undecorated classes with Angular features. +// Migrations for these patterns ran as part of `ng update` and we want to ensure +// that projects do not regress. See https://hackmd.io/@alx/ryfYYuvzH for more details. +export const compileUndecoratedClassesWithAngularFeatures = false;