JSPM

ng-packagr

1.0.0-alpha.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 875535
  • Score
    100M100P100Q191561F
  • License MIT

Compile and package a TypeScript library to Angular Package Format

Package Exports

  • ng-packagr/lib/util/log

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ng-packagr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ng-packagr

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": [
      "node_modules/@types"
    ],
    "lib": [
      "dom",
      "es2015"
    ]
  },
  "exclude": [
    "node_modules",
    "dist",
    "**/*.ngfactory.ts",
    "**/*.shim.ts",
    "**/*.spec.ts"
  ],
  "files": [
    "src/public_api.ts"
  ]
}

Knowledge

Packaging Angular - Jason Aden