mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
committed by
Jessica Janiuk
parent
730af49171
commit
f457b6c26b
@@ -7,8 +7,8 @@ Such a solution can be built as Angular *libraries* and these libraries can be p
|
||||
An Angular library is an Angular [project](guide/glossary#project) that differs from an application in that it cannot run on its own.
|
||||
A library must be imported and used in an application.
|
||||
|
||||
Libraries extend Angular's base functionality.
|
||||
For example, to add [reactive forms](guide/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.
|
||||
Libraries extend Angular's base features.
|
||||
For example, to add [reactive forms](guide/reactive-forms) to an application, 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](guide/service-worker-intro) library to an Angular application is one of the steps for turning an application into a [Progressive Web App](https://developers.google.com/web/progressive-web-apps) \(PWA\).
|
||||
[Angular Material](https://material.angular.io) is an example of a large, general-purpose library that provides sophisticated, reusable, and adaptable UI components.
|
||||
|
||||
@@ -17,25 +17,25 @@ See [Using Published Libraries](guide/using-libraries).
|
||||
|
||||
## Creating libraries
|
||||
|
||||
If you have developed functionality that is suitable for reuse, you can create your own libraries.
|
||||
If you have developed features that are 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](guide/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](guide/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.
|
||||
Deciding to package features as a library is an architectural decision. It is comparable to deciding whether a feature 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.
|
||||
Packaging features 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 application.
|
||||
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 applications.
|
||||
This complexity can pay off when the library is being used in multiple applications.
|
||||
|
||||
<div class="alert is-helpful">
|
||||
|
||||
**NOTE**: <br />
|
||||
Libraries are intended to be used by Angular applications.
|
||||
To add Angular functionality to non-Angular web applications, use [Angular custom elements](guide/elements).
|
||||
To add Angular features to non-Angular web applications, use [Angular custom elements](guide/elements).
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user