I've read several times that barrels are not recommended by Angular, but I'm not seeing that officially anywhere. And on the Angular site I see where they say they are using them.
https://angular.io/guide/glossary#B
UPDATE: In an apparent update to the Angular documentation, the page I've linked to doesn't appear to mention barrels anymore. If anyone can find where they say they use those, or an example of such usage, please comment with a link.
A barrel is a way to rollup exports from several modules into a single convenient module. The barrel itself is a module file that re-exports selected exports of other modules.
A barrel, in Angular, is simply a module file which provides a centralized place for exporting components, interfaces, services etc. In turn, in your main module file, you make all imports from that single source that you defined in the barrel file.
Using Barrel exports are absolutely fine (it is just a way to simplify your import process)
If AOT compiler is not complaining about the build then it is fine.
you can read more about that here
https://medium.com/@adrianfaciu/barrel-files-to-use-or-not-to-use-75521cd18e65
https://basarat.gitbooks.io/typescript/docs/tips/barrel.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With