Custom decorators are stripped when using the AoT build flag
OS?
Mac OSX Sierra
Versions.
angular-cli: 1.0.0-beta.17
node: 6.2.1
os: darwin x64
Repro steps.
- Clone @ngrx/example-app
- Compile the project using the
--aotflag - Check the compiled copy of either effect service
- Note that the
@Effect()decorator from @ngrx/effects has been stripped from the classes
The log given by the failure.
No errors are thrown
@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 :

@hansl is working on it and we'll probably have a fix in next release ! :)
Nice, thanks for the update @maxime1992
There is a new version of the cli (beta.23), anyone knows if the fix for this is in there?
@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 Great, thanks!
Do you know why beta.23 is not publish to npm yet?
@nirgn975 see https://github.com/angular/angular-cli/issues/3618.
Just tried again with beta.24 and this appears to be fixed?
Temporary fix. All decorators are kept but file sizes are now larger
ok cool, thanks.
Decorators are no longer being stripped.
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 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).
@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).
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.
Angular cli removes standart decorators. That does't worked at same times AOT and Jit. How to disable deletion standart decorators?
@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
Any news about this? As soon as i compile it with --prod my decorators are removed.
Can i keep them?
Even standard decorators are removed.
ng build --prod
Please remove the deletion
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.