node package manager



Compile and package a TypeScript library to Angular Package Format

Usage Example

Create a configuration file .ng-packagr.json:

  "src": "my-lib-source-folder",
  "dest": "dist/my-lib",
  "workingDirectory": ".ng_build",
  "ngc": {
    "tsconfig": "tsconfig.lib.json"

The tsconfig file is located relative to the src folder, e.g. in `my-lib-source-folder/tsconfig.lib.json´. It must follow this conventions:

  • In "angularCompilerOptions":
    • use flatModuleId and flatModuleOutFile
    • set "strictMetadataEmit": true and "skipTemplateCodegen": true
  • Has one single entry file to the library in "files": []
    • it's recommended to name it src/public_api.ts and set in combination with "flatModuleOutFile": "index" (see above)
  • In "compilerOptions":
    • must transpile to a real ES2015 bundle with "target": "es2015" and "module": "es2015" (transformations to ES5 and legacy bundle formats are performed by the tool later)
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "flatModuleId": "@foo/bar",
    "flatModuleOutFile": "index",
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true
  "buildOnSave": false,
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "",
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "outDir": "src",
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "skipLibCheck": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "typeRoots": [
    "lib": [
  "exclude": [
  "files": [


Packaging Angular - Jason Aden