-
Notifications
You must be signed in to change notification settings - Fork 12k
Prod Mode Compiling Out TypeScript decorator metadata from external project #10584
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
Comments
@amcdnl does this repro fail at runtime with the changes you listed? If not, can you give me a repro that fails so I can see something failing and then try to fix it? |
What is worth noting is that the router plugin mentioned here uses ngxs internally and is then packaged with ng-packagr |
I looked into this a bit and it doesn't seem to have anything to do with production mode. Using this
And Angular CLI 6.0.0-rc.8,
I'm not sure why this happens but it doesn't seem like a Uglify or Build Optimizer problem. |
Btw if this isn't the same error as you are seeing, please provide a reproduction that I can clone and shows the right one. |
Can you try adding the router module and see if that gets you to the wrror? |
*error |
@filipesilva = whops, I forgot to tell you to include the angular router. There is no runtime error, it compiles out the code so nothing actually runs on those decorators. |
@filipesilva @deebloo - Here is a github repo showing the issue - https://github.com/amcdnl/cli-prod-issue Just do |
I also fixed an issue where my TypeScript enums were getting compiled out too. I had a enum like: export enum Foo {
Bar = 'BAR'
} and it was resolving to export const enum Foo {
Bar = 'BAR'
} and it worked then. I wonder if that is related to this too. |
@amcdnl I have used your repro and can confirm I see the problem. @clydin and I have analysed what's happening and can explain what's going wrong. These libraries have If you look at your gist: https://gist.github.com/amcdnl/0236f4849e2941b279113a5589cef44b#file-compiled-js-L207-L230:
The toplevel I am not sure if you added If you remove it directly in your |
Can confirm adding that fixed the issue. thanks for your help! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Observed behavior
The cli in prod mode is compiling out the typescript decorator (custom decorator) metadata from a external project compiled using ng-packagr.
An example of the decorator metadata would be:
The result can be seen in this screenshot on the left:
It seems to be related to only external projects. I'm using the same custom decorator used in this code in my project and it works fine.
Desired behavior
It not to compile this out.
Repro steps
npm i @ngxs/router-plugin @ngxs/store
For reference here is the compiled code
Versions
Node 10
Npm 6
Mac
"@angular/cli": "^6.0.0-rc.8",
Mention any other details that might be useful (optional)
The text was updated successfully, but these errors were encountered: