UNPKG

ng-packagr

Version:

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

1 lines 4.72 kB
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../../src/lib/ng-package/package.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAI7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAa,SAAS;IACpB,YACmB,QAAgB;IACjC;;OAEG;IACa,OAAqB;IACrC;;OAEG;IACa,cAA8B,EAAE;QAR/B,aAAQ,GAAR,QAAQ,CAAQ;QAIjB,YAAO,GAAP,OAAO,CAAc;QAIrB,gBAAW,GAAX,WAAW,CAAqB;IAC/C,CAAC;IAEJ,wGAAwG;IACxG,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,sCAAsC;IACtC,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC7C,CAAC;IAED,4DAA4D;IAC5D,IAAW,IAAI;QACb,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjE,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC;IAED,IAAW,oBAAoB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACnD,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,IAAW,mBAAmB;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAClD,CAAC;IAED,IAAW,0BAA0B;QACnC,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,CAAC;QAChC,MAAM,0BAA0B,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAa,CAAC;QAE/F,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,0BAA0B,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;IAEM,UAAU,CAAC,QAAgB;QAChC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IAClG,CAAC;CACF;AApDD,8BAoDC","sourcesContent":["import * as path from 'path';\nimport { AssetPattern, NgPackageConfig } from '../../ng-package.schema';\nimport { NgEntryPoint } from './entry-point/entry-point';\n\n/**\n * A package being built. Quoting Angular Package Format, a package is:\n *\n * > the smallest set of files that are published to NPM and installed together, for example\n * > `@angular/core`. (..) The package is installed with `npm install @angular/core`.\n *\n * #### Package and Entry Points\n *\n * A package is composed of several (one or more) entry points.\n * A package must contain at least the primary entry point but can have many secondary entry\n * points.\n * The module ID of the primary entry point, e.g. `@angular/core`, matches the package name, e.g.\n * the package name is given to the command `npm install @angular/core`.\n * The source code files within a package are referenced by the entry points.\n *\n * #### Representation in the domain\n *\n * A _Package_ is reflected by `NgPackage`.\n * An _Entry Point_ is reflected by `NgEntryPoint`.\n * One `NgPackage` relates to one (or many) `NgEntryPoint`,\n * one `NgEntryPoint` relates to one `NgPackage`.\n *\n * #### Watch Out\n *\n * The user's configuration `ngPackage` suggests that it reflects a `NgPackage`.\n * However, the values given in the `lib` property reflect an `NgEntryPoint`.\n * In case the package contains only one entry point, `ngPackage.lib` reflects the primary entry\n * point.\n *\n * @link https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#\n */\nexport class NgPackage {\n constructor(\n private readonly basePath: string,\n /**\n * A reference to the primary entry point.\n */\n public readonly primary: NgEntryPoint,\n /**\n * An array of secondary entry points.\n */\n public readonly secondaries: NgEntryPoint[] = [],\n ) {}\n\n /** Absolute path of the package's source folder, derived from the user's (primary) package location. */\n public get src(): string {\n return this.basePath;\n }\n\n /** Delete output path before build */\n public get deleteDestPath(): boolean {\n return this.primary.$get('deleteDestPath');\n }\n\n /** Absolute path of the package's destination directory. */\n public get dest(): string {\n const dest = path.join(this.basePath, this.primary.$get('dest'));\n\n return dest.endsWith('/') ? dest.slice(0, -1) : dest;\n }\n\n public get keepLifecycleScripts(): boolean {\n return this.primary.$get('keepLifecycleScripts');\n }\n\n public get assets(): AssetPattern[] {\n return this.primary.$get('assets');\n }\n\n public get inlineStyleLanguage(): NgPackageConfig['inlineStyleLanguage'] {\n return this.primary.$get('inlineStyleLanguage');\n }\n\n public get allowedNonPeerDependencies(): string[] {\n const alwaysInclude = ['tslib'];\n const allowedNonPeerDependencies = this.primary.$get('allowedNonPeerDependencies') as string[];\n\n return Array.from(new Set([...allowedNonPeerDependencies, ...alwaysInclude]));\n }\n\n public entryPoint(moduleId: string): NgEntryPoint {\n return [this.primary, ...this.secondaries].find(entryPoint => entryPoint.moduleId === moduleId);\n }\n}\n"]}