-
Notifications
You must be signed in to change notification settings - Fork 311
Custom decorators are stripped from AoT builds as of 0.0.47 #545
Comments
I think this should be a bug of angular. angular/angular-cli#2799 |
That issue only applies to the angular cli. Ionic doesn't use the angular cli so therefore I don't believe it is relevant.
|
|
I've produced a minimal reproduction via the repository at https://github.com/fiznool/counter-ionic2-ngrx-effects which demonstrates the issue for 0.0.47 but not 0.0.46. So chances are you are seeing some other issue. One thing to watch out for is the syntax for |
Maybe you're right. |
This is something we'll need to investigate. We are removing decorators because decorators prevent code from being tree shakeable. We'll chat with Rob for Angular about Thanks, |
Meanwhile, is there a config option we can use to disable this behaviour? |
I don't know if it makes any difference but there is a temporary fix available from the angular team to preserve custom decorators. |
Thank u for the suggestion @fiznool. What file do we need to modify in a Ionic project to get it still works? |
Hi all, This is resolved in Please let me know if you have any issues. Thanks, |
I still have the same problem as before. I've just given a try on @fiznool test repo upgrading app-scripts version to 0.0.48. |
@danbucholtz could you confirm that this fix is in place for webpack builds? I can see from the relevant commit that this appears to be in place for rollup builds only, but perhaps I'm mistaken. |
Yeah, that is the correct commit. I don't think we actually do that process for Thanks, |
I guess this needs to be re-opened then, if the change hasn't been applied to the default (webpack) build? Presumably webpack is what 99% of people are using? |
@Francesco1992 @fiznool @joewoodhouse @danbucholtz Decorators are removed in webpack build as well - look at aot-compiler.ts, there is a method removeDecorators from utils/typescript-utils.ts, which is executed during AoT compilation. I've just tested and when removeDecorators are not executed everything works as expected. https://github.com/driftyco/ionic-app-scripts/blob/master/src/aot/aot-compiler.ts#L127 |
I am thinking I am misunderstanding how Thanks, |
@danbucholtz the most minimal reproduction can be found at the repo linked above in the original issue. It's an Ionic app which uses ngrx/effects. Here's the link again: https://github.com/fiznool/counter-ionic2-ngrx-effects |
@danbucholtz Just to clarify - I'm not using ngrx, but rather I have my own decorators for JSON serialization and those decorators are removed as well. I really don't understand why decorators must be removed... I can understand, that angular decorators must be removed in AoT, as they are not needed, but all others are as important and needed as any other js code. |
Decorators fundamentally make code not tree shakable. We'll do some more experimentation. We're not big fans of decorators as it stands now. We'll have to figure this out. Thanks, |
@danbucholtz Ok, that is a good point, but... afaik webpack by default doesn't do tree shaking? |
@lleevvyy, it does but not a very good job of it. This is something we're focused on. We want 200KB bundles, not 2000KB bundles 😄 Thanks, |
@danbucholtz Indeed, that would be something :-) In my app's case, js output is almost 3000KB, however... I need those decorators as well :-) :-) Thanks for you work guys, I'm really appreciated! |
I have the exactly same issue. My app's production build is completely broken after the upgrade to ionic 2 rc.4 with ionic-app-scripts 0.0.48, as I use ngrx/store with ngrx/effects almost everywhere. At least now I know the reason. I must temporary downgrade until there's some solution of this issue :(. |
If I'm following this correctly, decorators are preserved if you use rollup to build for production. As per the docs, setting If you wanted to stick with webpack for dev mode and switch to rollup for production builds, I have no idea how that would work though! |
@fiznool I have tried that, but I have issues with 3rd party libraries and rollup. Will see if I can fix them with custom config file, it's not working for now. Thanks! |
Meanwhile you can use |
I made a production build with rollup with |
@lleevvyy Thanks a lot! This one is the only way, which works for me too. Most probably will use it as a temporary hack until a solution appears. |
@lleevvyy great work in figuring out a workaround. I've submitted a PR which adds this in. IMHO the workaround is sound, because this is the approach the Angular team are taking with the |
@danbucholtz has there been any further discussion / progress within the Ionic team regarding this issue? |
I can merge your PR for Thanks, |
This issue will be resolved in Thanks, |
We published Thanks, |
Short description of the problem:
An app which uses custom decorators (e.g.
ngrx/effects
) has those decorators stripped from the resulting production build.What behavior are you expecting?
The custom decorators to not be stripped, as is the case in 0.0.46.
Steps to reproduce:
app-scripts-47
npm install
ionic run android --aot
(orios
)The 'Reset' button uses
ngrx/effects
, which in turn depends on a custom decorator,@Effect
. This is stripped from the build with 0.0.47 so the effect does not run, and hence the counter is not reset.Which @ionic/app-scripts version are you using?
0.0.47
Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
Using
ngrx/effects
involves a custom decorator,@Effects
. There are reports elsewhere in the Angular community that custom decorators are stripped from AoT builds in certain conditions (see here).Here is an output of the compiled
effects/counter.ts
module in 0.0.46 and 0.0.47. Notice that the decorators are preserved in the former but stripped in the latter.0.0.46
0.0.47
The text was updated successfully, but these errors were encountered: