Skip to content

feat(@ngtools/webpack): Allows to keep the decorators in AOT production #12179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ngtools/webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion packages/ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ export interface AngularCompilerPluginOptions {

host?: virtualFs.Host<fs.Stats>;
platformTransformers?: ts.TransformerFactory<ts.SourceFile>[];

// Allows to keep the decorators in AOT production as an option.
keepAotRemoveDecorators?: boolean;
}

export enum PLATFORM {
Expand Down Expand Up @@ -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));
}
Expand Down