DEV Community

loading...
Cover image for The Best Way To Architect Your Angular Libraries

The Best Way To Architect Your Angular Libraries

tomastrajan profile image Tomas Trajan 🐻 ・1 min read

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...

Discussion (0)

pic
Editor guide