DEV Community

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

Posted on

4 1

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

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn 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

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay