DEV Community

Cover image for The Best Way To Architect Your Angular Libraries
Tomas Trajan 🇨🇭
Tomas Trajan 🇨🇭

Posted on

The Best Way To Architect Your Angular Libraries

The context

The ideas presented in this article are based on extensive experience from large enterprise environment (100 Angular SPAs and 30+ libs )…

To be more precise, the initial impulse to explore this topic was creation of a second “component framework” (think internal Angular Material) following this approach and comparing it to the original one which does NOT use the ng-packagr sub-entries…

What we’re going to learn

  • How to create Angular library implementing clean architecture from scratch (demo project included)
  • How to implement sub-entry per feature (and how to simplify the process using ng-samurai schematics)
  • How to define proper Typescript “paths” aliases
  • How this architecture and setup automatically saves us from using incorrect imports or introducing circular dependencies
  • How to analyze our library structure with madge
  • How to consumer library in other applications
  • How to make stuff private
  • How to bring dependencies into consumer applications (dependencies vs peer dependencies)
  • How to create demo application for a library in local workspace
  • How to make this work with jest

Read more...

Top comments (1)

Collapse
 
sk6 profile image
samuelkomera6

After publishing the package I was able to import the module from @library/src/lib/modulename instead how can I import module from @library/modulename