From 0709ed4c2be3a9673e961c569644f2cc8d330598 Mon Sep 17 00:00:00 2001 From: Judy Bogart Date: Wed, 24 Jul 2019 12:58:42 -0700 Subject: [PATCH] docs: add doc for compiler options (#31829) PR Close #31829 --- aio/content/guide/angular-compiler-options.md | 148 +++++++++++++ aio/content/guide/aot-compiler.md | 203 +----------------- aio/content/guide/deprecations.md | 2 +- aio/content/navigation.json | 5 + 4 files changed, 157 insertions(+), 201 deletions(-) create mode 100644 aio/content/guide/angular-compiler-options.md diff --git a/aio/content/guide/angular-compiler-options.md b/aio/content/guide/angular-compiler-options.md new file mode 100644 index 0000000000..6775254bd8 --- /dev/null +++ b/aio/content/guide/angular-compiler-options.md @@ -0,0 +1,148 @@ +# Angular compiler options + +When you use [AOT compilation](guide/aot-compiler), you can control how your application is compiled by specifying *template* compiler options in the `tsconfig.json` [TypeScript configuration file](guide/typescript-configuration). + +The template options object, `angularCompilerOptions`, is a sibling to the `compilerOptions` object that supplies standard options to the TypeScript compiler. + +```json + { + "compilerOptions": { + "experimentalDecorators": true, + ... + }, + "angularCompilerOptions": { + "fullTemplateTypeCheck": true, + "preserveWhitespaces": true, + ... + } + } + ``` +This page describes the available Angular template compiler options. + +### `allowEmptyCodegenFiles` + +When true, generate all possible files even if they are empty. Default is false. Used by the Bazel build rules to simplify how Bazel rules track file dependencies. Do not use this option outside of the Bazel rules. + +### `annotationsAs` + +Modifies how Angular-specific annotations are emitted to improve tree-shaking. Non-Angular annotations are not affected. One of `static fields` (the default) or `decorators`. + +* By default, the compiler replaces decorators with a static field in the class, which allows advanced tree-shakers like [Closure compiler](https://github.com/google/closure-compiler) to remove unused classes. + +* The `decorators` value leaves the decorators in place, which makes compilation faster. TypeScript emits calls to the` __decorate` helper. Use `--emitDecoratorMetadata` for runtime reflection (but note taht the resulting code will not properly tree-shake. + +### `annotateForClosureCompiler` + +When true, use [Tsickle](https://github.com/angular/tsickle) to annotate the emitted JavaScript with [JSDoc](http://usejsdoc.org/) comments needed by the +[Closure Compiler](https://github.com/google/closure-compiler). Default is false. + +### `disableExpressionLowering` + +When true (the default), transforms code that is or could be used in an annotation, to allow it to be imported from template factory modules. See [metadata rewriting](guide/aot-compiler#metadata-rewriting) for more information. + +When `false`, disables this rewriting, requiring the rewriting to be done manually. + +### `disableTypeScriptVersionCheck` + +When `true`, the compiler does not check the TypeScript version and does not report an error when an unsupported version of TypeScript is used. Not recommended, as unsupported versions of TypeScript might have undefined behavior. Default is false. + +### `enableResourceInlining` + +When true, replaces the `templateUrl` and `styleUrls` property in all `@Component` decorators with inlined contents in `template` and `styles` properties. + +When enabled, the `.js` output of `ngc` does not include any lazy-loaded template or style URLs. + + +{@a enablelegacytemplate} + +### `enableLegacyTemplate` + +When true, enables use of the `