-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Explicitly exporting each component in the base index.ts file #184
Conversation
…e index.ts. Barrel exports of components cause @ViewChild(<className>) to give undefined in AOT builds
Is this only necessary for the components, not also for the directives? |
@ZachRHale Thanks for the solution, @madoar , can you accept the pull request? it looks many people are getting this issue. |
@YousefMMS I would like to first have an answer to my question above. |
I know that a lot of people are using only the components. Still it would be best to know now, whether the same changes are also required for the directives, maybe @ZachRHale knows? Just in case we could also think about changing all the exports like suggested for the components? |
I'm not sure as I haven't used ViewChild/ViewChildren on directives but a Component is a type of Directive with a template, so I would assume that you should do the same for the Directives. |
@ZachRHale thank you for your evaluation. Do you want to do the changes for the directives (maybe also the other classes?) inside this PR or should I do it in a new one? |
I guess it depends. I may be able to do it today, otherwise I'm pretty busy Sunday and the rest of next week. If you have more time then we can make another PR. Also, having this one merge in could help the people who have Component issues at the moment. |
Ok, then I'll merge this now and then do the changes for the other classes later :) |
* master: - adjust version - add angular version 7 to the keywords - fix badges in README Update to angular 7 (madoar#194) Update the badges (madoar#193) Cleanup .travis.yml (madoar#191) Remove unnecesarry index.ts files (madoar#192) Apply the [stepId] field from the WizardSteps at ids in the navigation bar (madoar#186) Update the index.ts files (madoar#187) Removing barrel export and explicitly exporting each component in base index.ts. Barrel exports of components cause @ViewChild(<className>) to give undefined in AOT builds (madoar#184) Declare Angular 7 compatibility in `package.json` (madoar#165) Refactor styles (madoar#161) Restore vertical nav bar layout, in particular label alignment (madoar#159)
Using barrel exports with ng-packagr can have strange side-effects when using the package in an AOT production build.
This is for issue #131 which I discovered would be fixed by explicitly exporting each component in the index.ts
Since it is impossible to currently write unit tests for Angular AOT builds, I created a small Angular application that used the angular-archwizard package with my changes and verified that the reference to the @ViewChild() component is defined with an AOT build served with Express.js.