From 989b3047d01dfb7cb0a4e595c1e03807083d1b51 Mon Sep 17 00:00:00 2001 From: patrikx3 Date: Wed, 5 Sep 2018 18:15:13 +0200 Subject: [PATCH] feat(@ngtools/webpack): Allows to keep the decorators in AOT production --- packages/ngtools/webpack/README.md | 1 + packages/ngtools/webpack/src/angular_compiler_plugin.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ngtools/webpack/README.md b/packages/ngtools/webpack/README.md index 9e6f6bb3f3f5..065841828237 100644 --- a/packages/ngtools/webpack/README.md +++ b/packages/ngtools/webpack/README.md @@ -43,6 +43,7 @@ The loader works with webpack plugin to compile your TypeScript. It's important * `sourceMap`. Optional. Include sourcemaps. * `compilerOptions`. Optional. Override options in `tsconfig.json`. * `contextElementDependencyConstructor`. Optional. Set to `require('webpack/lib/dependencies/ContextElementDependency')` if you are having `No module factory available for dependency type: ContextElementDependency` errors. +* `keepAotRemoveDecorators`, Optional. Allows to keep the decorators in AOT production. ## Features The benefits and ability of using [`@ngtools/webpack`](https://www.npmjs.com/~ngtools) standalone from the Angular CLI as presented in [Stephen Fluin's Angular CLI talk](https://youtu.be/uBRK6cTr4Vk?t=6m45s) at Angular Connect 2016: diff --git a/packages/ngtools/webpack/src/angular_compiler_plugin.ts b/packages/ngtools/webpack/src/angular_compiler_plugin.ts index e4c9da15354f..824968698622 100644 --- a/packages/ngtools/webpack/src/angular_compiler_plugin.ts +++ b/packages/ngtools/webpack/src/angular_compiler_plugin.ts @@ -103,6 +103,9 @@ export interface AngularCompilerPluginOptions { host?: virtualFs.Host; platformTransformers?: ts.TransformerFactory[]; + + // Allows to keep the decorators in AOT production as an option. + keepAotRemoveDecorators?: boolean; } export enum PLATFORM { @@ -816,7 +819,7 @@ export class AngularCompilerPlugin { if (this._JitMode) { // Replace resources in JIT. this._transformers.push(replaceResources(isAppPath)); - } else { + } else if (this._options.keepAotRemoveDecorators !== true) { // Remove unneeded angular decorators. this._transformers.push(removeDecorators(isAppPath, getTypeChecker)); }