Search code examples
angularangular-rc5

angular 2 RC5 ngModules vs. barrels


In our project we are moving from Angular 2 RC4 to RC5.

Question is: with the introduction of ngModules, will the barrels (index files) become unnecessary? Or can you use both in parallel? how to use these 2 concepts?


Solution

  • Barrels are to simplify TypeScript imports and are optional.
    They aren't recommended anymore by the Angular2 team because they often cause issues with circular dependencies and similar.

    @NgModule()s are Angular2 compilation units. @NgModule() and are an entirely different and unrelated concept and mandatory.