Skip to content
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

Merged
merged 1 commit into from
Feb 14, 2019

Conversation

ZachRHale
Copy link
Contributor

@ZachRHale ZachRHale commented Jan 19, 2019

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.

…e index.ts. Barrel exports of components cause @ViewChild(<className>) to give undefined in AOT builds
@madoar
Copy link
Owner

madoar commented Jan 30, 2019

Is this only necessary for the components, not also for the directives?

@YousefMMS
Copy link

@ZachRHale Thanks for the solution, @madoar , can you accept the pull request? it looks many people are getting this issue.

@madoar
Copy link
Owner

madoar commented Feb 7, 2019

@YousefMMS I would like to first have an answer to my question above.
I simply don't know enough about the reason for the error to answer the question myself, but I think it is quite likely that when injecting a directive you get the same error. Therefore I would like to fix both problems in one go.

@YousefMMS
Copy link

YousefMMS commented Feb 7, 2019

@madoar I'm only using the components, I did not use any directives, and I'm controlling the steps throw a reference on the component using viewchild.

And btw, #116 solved my issue.

@madoar
Copy link
Owner

madoar commented Feb 7, 2019

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?

@ZachRHale
Copy link
Contributor Author

Is this only necessary for the components, not also for the directives?

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.

@madoar
Copy link
Owner

madoar commented Feb 9, 2019

@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?

@ZachRHale
Copy link
Contributor Author

ZachRHale commented Feb 9, 2019

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.

@madoar
Copy link
Owner

madoar commented Feb 14, 2019

Ok, then I'll merge this now and then do the changes for the other classes later :)

@madoar madoar merged commit 4851e39 into madoar:develop Feb 14, 2019
@madoar madoar mentioned this pull request Feb 14, 2019
earshinov added a commit to earshinov/angular-archwizard that referenced this pull request Mar 17, 2019
* 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)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants