![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ng-packagr
Advanced tools
ng-packagr is a tool for building and packaging Angular libraries in a way that is compatible with the Angular Package Format (APF). It helps developers to create reusable Angular libraries that can be easily distributed and consumed by other Angular applications.
Library Packaging
This command packages an Angular library according to the configuration specified in the ng-package.json file. It compiles the TypeScript code, bundles the library, and generates metadata files.
ng-packagr -p ng-package.json
Configuration File
The ng-package.json file is used to configure the packaging process. It specifies the destination directory for the packaged library and the entry file for the library.
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "dist/my-lib",
"lib": {
"entryFile": "src/public-api.ts"
}
}
Custom Build Steps
You can add custom build steps in your package.json file to automate the packaging process. This example shows how to add a build script that runs ng-packagr with the specified configuration file.
{
"scripts": {
"build": "ng-packagr -p ng-package.json"
}
}
ngx-build-plus is an Angular CLI extension that allows for more advanced build customizations. It provides features like extending the Angular build process, adding custom webpack configurations, and more. Compared to ng-packagr, ngx-build-plus is more focused on extending and customizing the build process of Angular applications rather than packaging libraries.
angular-library-builder is another tool for building Angular libraries. It provides a simple and straightforward way to package Angular libraries, similar to ng-packagr. However, it may not support all the advanced features and configurations that ng-packagr offers.
Compile and package Angular libraries in Angular Package Format (APF)
npm install -D ng-packagr
Let's walk through a getting started that'll build an Angular library from TypeScript sources and create a distribution-ready npm package:
create a ng-package.json
file and run ng-packagr -p ng-package.json
– Here we go:
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
...
}
You can easily run ng-packagr through a npm/yarn script:
{
"scripts": {
"build": "ng-packagr -p ng-package.json"
}
}
Now, execute the build with the following command:
$ yarn build
The build output is written to the dist
folder, containing all those binaries to meet the Angular Package Format specification.
You'll now be able to go ahead and npm publish dist
your Angular library to the npm registry.
Do you like to publish more libraries?
Is your code living in a monorepo?
Create one package.json
per npm package, run ng-packagr for each!
.d.ts
).browserslistrc
Angular Package Format documentation
Packaging Angular Libraries - Jason Aden at Angular Mountain View Meetup (Jan 2018, 45min talk)
Create and publish Angular libs like a Pro - Juri Strumpflohner at NG-BE (Dec 2017, 30min talk)
Packaging Angular - Jason Aden at ng-conf 2017 (28min talk)
Create and publish Angular libs like a Pro - Juri Strumpflohner at ngVikings, this time demoing building Angular libraries with ng-packagr, with NX as well as Bazel (March 2018, 30min talk)
General contribution guidelines
If you like to submit a pull request, you'll find it helpful to take a look at the initial design document where it all started.
To orchestrate the different tools, ng-packagr features a custom transformation pipeline. The transformation pipeline is built on top of RxJS and Angular Dependency Injection concepts.
FAQs
Compile and package Angular libraries in Angular Package Format (APF)
The npm package ng-packagr receives a total of 0 weekly downloads. As such, ng-packagr popularity was classified as not popular.
We found that ng-packagr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.