MCPcopy
hub / github.com/ng-packagr/ng-packagr

github.com/ng-packagr/ng-packagr @22.0.1 sqlite

repository ↗ · DeepWiki ↗ · release 22.0.1 ↗
562 symbols 1,323 edges 270 files 59 documented · 10%
README

ng-packagr

Compile and package Angular libraries in Angular Package Format (APF)

npm npm License CircleCI

GitHub stars npm Downloads Renovate enabled

Installation

npm install -D ng-packagr

Usage Example

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!

Features

  • :gift: Implements Angular Package Format
  • :checkered_flag: Bundles your library in FESM2022
  • :school_satchel: npm package can be consumed by Angular CLI, Webpack, or ESM Bundlers
  • :dancer: Creates type definitions (.d.ts)
  • :mag_right: Creates scoped and non-scoped packages for publishing to npm registry
  • :surfer: Inlines Templates and Stylesheets
  • :sparkles: CSS Features
  • :camel: Runs SCSS preprocessor, supporting custom include paths
  • :monkey: Adds vendor-specific prefixes
  • :tiger: Embed assets data

How to…

Knowledge

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)

Juri Strumpflohner - Create and publish Angular libs like a Pro

Packaging Angular - Jason Aden at ng-conf 2017 (28min talk)

Packaging Angular - Jason Aden

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)

Juri Strumpflohner - Create & Publish Angular Libs like a PRO at ngVikings

Contributing to ng-packagr

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.

Extension points exported contracts — how you extend this code

LoadResultCache (Interface)
(no doc) [4 implementers]
src/lib/styles/load-result-cache.ts
Foo (Interface)
(no doc)
integration/samples/core/src/foobar.interface.ts
NodeModule (Interface)
(no doc)
integration/consumers/ng-cli/src/typings.d.ts
Foo (Interface)
(no doc)
integration/watch/basic/test_files/new-file/dummy.ts
RenderResponseMessage (Interface)
* A response from the Sass render Worker containing the result of the operation.
src/lib/styles/sass/sass-service.ts
Bar (Interface)
(no doc)
integration/samples/core/src/foobar.interface.ts
RenderRequestMessage (Interface)
* A request to render a Sass stylesheet using the supplied options.
src/lib/styles/sass/worker.ts
TestInterface (Interface)
(no doc)
integration/samples/ivy/src/angular.module.ts

Core symbols most depended-on inside this repo

get
called by 32
src/lib/styles/cache.ts
has
called by 25
src/lib/styles/cache.ts
readFileSync
called by 20
integration/watch/test-harness.ts
set
called by 19
src/lib/styles/cache.ts
getOrCreate
called by 19
src/lib/styles/cache.ts
copyTestCase
called by 17
integration/watch/test-harness.ts
$get
called by 15
src/lib/ng-package/entry-point/entry-point.ts
delete
called by 12
src/lib/file-system/file-cache.ts

Shape

Class 231
Method 158
Function 131
Interface 39
Enum 3

Languages

TypeScript100%

Modules by API surface

src/lib/styles/sass/rebasing-importer.ts19 symbols
src/lib/styles/cache.ts19 symbols
src/lib/ng-package/entry-point/entry-point.ts17 symbols
integration/watch/test-harness.ts17 symbols
src/lib/styles/sass/sass-service.ts16 symbols
src/lib/ng-package/nodes.ts16 symbols
src/lib/graph/build-graph.ts16 symbols
src/lib/styles/stylesheets/stylesheet-plugin-factory.ts13 symbols
src/lib/styles/bundler-context.ts13 symbols
src/lib/packagr.ts12 symbols
src/lib/styles/stylesheets/less-language.ts11 symbols
src/lib/ng-package/package.ts11 symbols

Dependencies from manifests, versioned

@ampproject/remapping2.3.0 · 1×
@angular/build22.0.0-next · 1×
@angular/cdk22.0.0-next · 1×
@angular/cli22.0.0-next · 1×
@angular/common22.0.0-next.3 · 1×
@angular/compiler22.0.0-next.3 · 1×
@angular/compiler-cli22.0.0-next.3 · 1×
@angular/core22.0.0-next.3 · 1×
@angular/forms22.0.0-next · 1×
@angular/material22.0.0-next · 1×
@angular/ng-devhttps://github.com/a · 1×
@angular/platform-browser22.0.0-next.3 · 1×

For agents

$ claude mcp add ng-packagr \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact