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

Custom decorators are stripped when using the AoT build flag

Open MikeRyanDev opened this issue 10 years ago • 39 comments

OS?

Mac OSX Sierra

Versions.

angular-cli: 1.0.0-beta.17
node: 6.2.1
os: darwin x64

Repro steps.

  1. Clone @ngrx/example-app
  2. Compile the project using the --aot flag
  3. Check the compiled copy of either effect service
  4. Note that the @Effect() decorator from @ngrx/effects has been stripped from the classes

The log given by the failure.

No errors are thrown

MikeRyanDev avatar Oct 20 '16 12:10 MikeRyanDev

@petercn I did try to rebase from the original repo and things got broken. If you have some trouble to use it too, you should git checkout the (only) commit I've made.

There is an update tho : image

@hansl is working on it and we'll probably have a fix in next release ! :)

maxime1992 avatar Dec 08 '16 18:12 maxime1992

Nice, thanks for the update @maxime1992

petercn avatar Dec 08 '16 18:12 petercn

There is a new version of the cli (beta.23), anyone knows if the fix for this is in there?

nirgn975 avatar Dec 18 '16 07:12 nirgn975

@nirgn975 yes, a temporary fix via PR https://github.com/angular/angular-cli/pull/3583 is in while they implement a better permanent solution.

Splaktar avatar Dec 18 '16 07:12 Splaktar

@Splaktar Great, thanks! Do you know why beta.23 is not publish to npm yet?

nirgn975 avatar Dec 18 '16 08:12 nirgn975

@nirgn975 see https://github.com/angular/angular-cli/issues/3618.

Splaktar avatar Dec 18 '16 18:12 Splaktar

Just tried again with beta.24 and this appears to be fixed?

SethDavenport avatar Dec 27 '16 19:12 SethDavenport

Temporary fix. All decorators are kept but file sizes are now larger

clydin avatar Dec 27 '16 19:12 clydin

ok cool, thanks.

SethDavenport avatar Dec 27 '16 19:12 SethDavenport

Decorators are no longer being stripped.

Brocco avatar Jan 22 '17 16:01 Brocco

Aren't they stripped again? I'm using custom decorator and it's being stripped on latest version of @ngtools/webpack Can anyone confirm what's the current approach for custom decorators? cc @Brocco

KKrisu avatar Mar 30 '17 12:03 KKrisu

@KKrisu this is weird. Which version of cli / angular are you using ?

I don't have that problem (and I'm using ngrx/effects, custom decorators were stripped before but not anymore).

maxime1992 avatar Mar 30 '17 14:03 maxime1992

@KKrisu I suggest using https://github.com/shlomiassaf/ngc-webpack instead of @ngtools/webpack, it seems way much more mature/stable (at least in present).

xaralis avatar Mar 31 '17 07:03 xaralis

Hey, @maxime1992 I'm on @ngtools/[email protected] I have totally custom decorator built on our own. So the decorator body looks like this:

export function Embeddable(key: string) {
  return function(componentClass: Function) {
    // our custom code
  }
}

then in components

import { Embeddable } from '...';
@Embeddable('link')
@Component({
...

@xaralis thank you, I will consider this alternative if we have more problems, currently, this is the only one with the decorator.

KKrisu avatar Mar 31 '17 08:03 KKrisu

Angular cli removes standart decorators. That does't worked at same times AOT and Jit. How to disable deletion standart decorators?

Alekcei avatar Jul 03 '17 06:07 Alekcei

@Brocco Just wonder when you say decorators are not striped, do you have fix number? It seems it stills removes them. The standard angular ones. , I just need to keep @Input(), @Output(), nothing else.

I see in the code (ngtools):

 if (!plugin.skipCodeGeneration) {
                return Promise.resolve()
                    .then(() => _removeDecorators(refactor))
                    .then(() => _replaceBootstrap(plugin, refactor));
            }

Is this is the solution ?

Thank you, Frank

fkolar avatar Jul 15 '17 05:07 fkolar

Any news about this? As soon as i compile it with --prod my decorators are removed.

Can i keep them?

DominicBoettger avatar Dec 01 '17 22:12 DominicBoettger

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

Alekcei avatar Dec 02 '17 21: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.