Overview of Angular libraries
许多应用都需要解决一些同样的常见问题，例如提供统一的用户界面、渲染数据，以及允许数据输入。开发人员可以为特定的领域创建一些通用解决方案，以便在不同的应用中重复使用。像这样的解决方案就可以构建成 Angular 库，这些库可以作为 npm 包进行发布和共享。
Many applications need to solve the same general problems, such as presenting a unified user interface, presenting data, and allowing data entry. Developers can create general solutions for particular domains that can be adapted for re-use in different apps. Such a solution can be built as Angular libraries and these libraries can be published and shared as npm packages.
Angular 库是一个 Angular 项目，它与应用的不同之处在于它本身是不能运行的。必须在某个应用中导入库并使用它。
An Angular library is an Angular project that differs from an app in that it cannot run on its own. A library must be imported and used in an app.
这些库扩展了 Angular 的基本功能。例如，要向应用添加响应式表单，请使用
ng add @angular/forms 添加该库的 npm 包，再从应用代码中，从
ReactiveFormsModule。同样，把 Service Worker 库添加到 Angular 应用中是将应用转换为渐进式 Web 应用程序（PWA）的步骤之一。Angular Material 是一个大型通用库的典范，它提供了一些复杂、可重用，兼具高度适应性的 UI 组件。
Libraries extend Angular's base functionality. For example, to add reactive forms to an app, add the library package using
ng add @angular/forms, then import the
ReactiveFormsModule from the
@angular/forms library in your application code. Similarly, adding the service worker library to an Angular application is one of the steps for turning an application into a Progressive Web App (PWA). Angular Material is an example of a large, general-purpose library that provides sophisticated, reusable, and adaptable UI components.
任何一位应用开发者都可以使用这样或那样的库，它们都已经由 Angular 团队或第三方发布为 npm 包。参见使用已发布的库。
Any app developer can use these and other libraries that have been published as npm packages by the Angular team or by third parties. See Using Published Libraries.
If you have developed functionality that is suitable for reuse, you can create your own libraries. These libraries can be used locally in your workspace, or you can publish them as npm packages to share with other projects or other Angular developers. These packages can be published to the npm registry, a private npm Enterprise registry, or a private package management system that supports npm packages. See Creating Libraries.
Whether you decide to package functionality as a library is an architectural decision, similar to deciding whether a piece of functionality is a component or a service, or deciding on the scope of a component.
Packaging functionality as a library forces the artifacts in the library to be decoupled from the application's business logic. This can help to avoid various bad practices or architecture mistakes that can make it difficult to decouple and reuse code in the future.
Putting code into a separate library is more complex than simply putting everything in one app. It requires more of an investment in time and thought for managing, maintaining, and updating the library. This complexity can pay off, however, when the library is being used in multiple apps.