BBaysinger
BBaysinger

Reputation: 6847

Are barrels in TypeScript / Angular 2+ not recommended nor best practice?

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.

Upvotes: 17

Views: 5909

Answers (1)

Jeba Prince
Jeba Prince

Reputation: 1671

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

Upvotes: 6

Related Questions