angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Custom decorators are stripped when using the ng build --prod

Open Alekcei opened this issue 8 years ago • 12 comments

Even standard decorators are removed. ng build --prod Please remove the deletion

Probably related https://github.com/angular/angular-cli/issues/8725

Alekcei avatar Dec 02 '17 21:12 Alekcei

I think this has something to do with @angular-devkit/build-optimizer but it supposedly should preserve the non-angular decorators?

Scrub file

Angular decorators, property decorators and constructor parameters are removed, while leaving non-Angular ones intact.

tomastrajan avatar Dec 04 '17 09:12 tomastrajan

Possible workaround, try running with --no-build-optimizer.

tomastrajan avatar Dec 04 '17 09:12 tomastrajan

It is intentional that Angular decorators are removed. What other decorators are you seeing removed? Can you tell me how to repro?

filipesilva avatar Dec 04 '17 17:12 filipesilva

Flag the flag helped --no-build-optimizer, I use JitCompilerFactory, styles and templates are not loaded. But they are not needed. I learned to take ViewCalss and renderType from AOT EntryComponets.

The request can be closed. Thank you very much

Alekcei avatar Dec 04 '17 17:12 Alekcei

@filipesilva when this is intentional what is the best way how to keep metadata after its compiled? In previous version all used to worked me where I updated loader.js and added tstickle style-like static properties to keep the metadataabout @Input,@output. Now when you introduce this full removal all starts again.

Cant you simply make it configurable so developers can specify what should be removed and what its not?

I can see the removeDecorator transformer is called before loader.js which before converted ctordecorator to static fields and now since we call remove decorator after all code in there is obsolete.

I need probably move my code that converts @Input,@Output into propDecorators into makeDecorators, before the removal is called.

fkolar avatar Dec 08 '17 23:12 fkolar

https://github.com/angular/angular-cli/issues/8997#issuecomment-354015987 Again disappeared decoratoes @angular/cli": "1.6.2" the flag --no-build-optimizer does not work I am used ./node_modules/.bin/ng build --prod --no-build-optimizer

Alekcei avatar Dec 26 '17 21:12 Alekcei

--no-build-optimizer not working in @angular/cli:1.6.2. But if use @angular/cli:1.5.0 then all Ok

Alekcei avatar Dec 27 '17 07:12 Alekcei

repo for reproduce https://github.com/Alekcei/no-build-optimizer contains two projects differing "@angular/cli": "1.5.0" and "@angular/cli": "1.6.2" testngcli150 works, the components are displayed testngcli162 not working, the components are don`t displayed

comand build ./node_modules/.bin/ng build --prod --no-build-optimizer

Alekcei avatar Dec 27 '17 18:12 Alekcei

Please see the problem Flag no-build-optimizer stopped working

Alekcei avatar Dec 27 '17 18:12 Alekcei

As @filipesilva stated above, AOT mode removes Angular decorators from the application code and this behavior is intentional. Not removing the decorators results in larger output bundles and slower production build times. The build optimizer is primarily responsible for library optimization and is not relevant to application decorator removal (it was erroneously in 1.5).

If custom (non-Angular decorators) are observed to be removed then this would indeed be a defect. In that case, please re-open the issue.

If the capability to keep Angular decorators in AOT mode is desired, then please consider opening a feature request. Please note, however, this does not guarantee that the feature will be implemented.

clydin avatar Dec 27 '17 18:12 clydin

The flag was entered --no-build-optimizer, disabling optimization, now it does not work All decorators are deleted

Alekcei avatar Dec 27 '17 19:12 Alekcei

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.