Angular Package vs Angular Library
When I start building the angular library for our project, most of the team member question is why not package? Both are similar in terms of usage. then why I chose the library.
Here I want to clarify what is different between a package and a library.
Package
The package has a specific goal. For example, ng2-select package goal creates the select box how the user wants. The package owner won’t add any new features to this package. He keeps on improvising the selectbox based user needs. this is how package works
Library
The library doesn’t have a specific goal. you have n number of applications under one domain/project, you found many features used by different applications.
We usually copy features from one application to a new application. What finally will happen is feature discrepancy.
How will the discrepancy happen?
In the new application, We want additional changes, most people will do changes in a new application. they will not do changes to the old one. it creates discrepancies in features.
How to resolve it
To resolve this situation, the angular team introduced the angular library in angular 6. you write it once and use it anywhere under your project.
For most of the developers, the next question is, If you have 20 features in the library, I want to use it only 2. Will it increase my build size?
To solve this question, We need to implement a secondary entry point in the library.
Once you implement a secondary entry point in the library, If you use only 2 features and imported the same, the particular features will be added into the build. It will add the whole library code to your application.
Package vs Library
The package creates one specific goal
The library is for the collection of features from one specific domain/project.
Happy Coding !!!