angular/packages/compiler-cli/private/tooling.ts
Paul Gschwendtner d74ee6e343 refactor(compiler-cli): group initializer-API based transforms into single transform (#54200)
Instead of maintaining individual transforms for `input`, `output`,
`model` etc. we are grouping them directly and the first one matching,
will execute.

This reduces needed traversal through AST and also makes it a little
more clean to write new initializer API metadata transforms.

Note: The Angular JIT transform is now also moving from `tooling.ts`
directly into `/transformers` for more local placement of transformer
logic.

PR Close #54200
2024-02-01 15:58:50 +00:00

43 lines
1.2 KiB
TypeScript

/**
* @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
*/
/**
* @fileoverview
* This file is used as a private API channel to shared Angular FW APIs with @angular/cli.
*
* Any changes to this file should be discussed with the Angular CLI team.
*/
import ts from 'typescript';
import {angularJitApplicationTransform} from '../src/transformers/jit_transforms/index';
/**
* Known values for global variables in `@angular/core` that Terser should set using
* https://github.com/terser-js/terser#conditional-compilation
*/
export const GLOBAL_DEFS_FOR_TERSER = {
ngDevMode: false,
ngI18nClosureMode: false,
};
export const GLOBAL_DEFS_FOR_TERSER_WITH_AOT = {
...GLOBAL_DEFS_FOR_TERSER,
ngJitMode: false,
};
/**
* JIT transform used by the Angular CLI.
*
* NOTE: Signature is explicitly captured here to highlight the
* contract various Angular CLI versions are relying on.
*/
export const constructorParametersDownlevelTransform =
(program: ts.Program, isCore = false): ts.TransformerFactory<ts.SourceFile> => {
return angularJitApplicationTransform(program, isCore);
};