ng-packagr 22.2.1 → 22.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "22.2.1",
3
+ "version": "22.2.3",
4
4
  "description": "Compile and package Angular libraries in Angular Package Format (APF)",
5
5
  "keywords": [
6
6
  "apf",
@@ -18,6 +18,7 @@ export interface Traversable<T> {
18
18
  * Technically, it's implemented as a map-like collection with references between map entries.
19
19
  */
20
20
  export declare class BuildGraph implements Traversable<Node> {
21
+ readonly isParallel: boolean;
21
22
  readonly store: Map<string, Node>;
22
23
  private _watcher?;
23
24
  constructor(store?: Map<string, Node>);
@@ -37,7 +38,8 @@ export declare class BuildGraph implements Traversable<Node> {
37
38
  export declare class ScopedBuildGraph<T extends Node = Node> extends BuildGraph {
38
39
  readonly parentGraph: BuildGraph;
39
40
  readonly activeEntryPoint: T;
40
- constructor(parentGraph: BuildGraph, activeEntryPoint: T);
41
+ readonly isParallel: boolean;
42
+ constructor(parentGraph: BuildGraph, activeEntryPoint: T, isParallel?: boolean);
41
43
  get watcher(): FSWatcher | undefined;
42
44
  set watcher(watcher: FSWatcher | undefined);
43
45
  }
@@ -8,6 +8,7 @@ const nodes_1 = require("../ng-package/nodes");
8
8
  * Technically, it's implemented as a map-like collection with references between map entries.
9
9
  */
10
10
  class BuildGraph {
11
+ isParallel = false;
11
12
  store;
12
13
  _watcher;
13
14
  constructor(store) {
@@ -89,10 +90,12 @@ exports.BuildGraph = BuildGraph;
89
90
  class ScopedBuildGraph extends BuildGraph {
90
91
  parentGraph;
91
92
  activeEntryPoint;
92
- constructor(parentGraph, activeEntryPoint) {
93
+ isParallel;
94
+ constructor(parentGraph, activeEntryPoint, isParallel = false) {
93
95
  super(parentGraph.store);
94
96
  this.parentGraph = parentGraph;
95
97
  this.activeEntryPoint = activeEntryPoint;
98
+ this.isParallel = isParallel;
96
99
  }
97
100
  get watcher() {
98
101
  return this.parentGraph.watcher;
@@ -1 +1 @@
1
- {"version":3,"file":"build-graph.js","sourceRoot":"","sources":["../../../../src/lib/graph/build-graph.ts"],"names":[],"mappings":";;;AA6IA,gDAEC;AA9ID,+CAAkD;AAqBlD;;;GAGG;AACH,MAAa,UAAU;IACZ,KAAK,CAAoB;IAC1B,QAAQ,CAAa;IAE7B,YAAY,KAAyB;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,IAAI,GAAG,EAAgB,CAAC;IAChD,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,OAAO,CAAC,OAA8B;QACxC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,GAAG,CAAC,KAAoB;QACtB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,MAAM,CAAC,IAAU;QACvB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,+BAA+B;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACzC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACtC,IAAI,OAAO,EAAE,CAAC;gBACZ,IA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AC;gBACb,OAAO,IAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AAhGD,gCAgGC;AAED,MAAa,gBAAwC,SAAQ,UAAU;IAE1D;IACA;IAFX,YACW,WAAuB,EACvB,gBAAmB;QAE5B,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAHhB,gBAAW,GAAX,WAAW,CAAY;QACvB,qBAAgB,GAAhB,gBAAgB,CAAG;IAG9B,CAAC;IAED,IAAa,OAAO;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,IAAa,OAAO,CAAC,OAA8B;QACjD,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;IACrC,CAAC;CACF;AAfD,4CAeC;AAED,SAAgB,kBAAkB,CAAwB,KAAiB;IACzE,OAAO,KAAK,YAAY,gBAAgB,CAAC;AAC3C,CAAC","sourcesContent":["import { FSWatcher } from 'chokidar';\nimport { fileUrlPath } from '../ng-package/nodes';\nimport { Node } from './node';\n\nexport type SimplePredicate<T = Node> = {\n (value: T): boolean;\n and?: (criteria: SimplePredicate<T>) => SimplePredicate<T>;\n};\n\nexport type ComplexPredicate<T = Node, R extends T = T> =\n | SimplePredicate<T>\n | {\n (value: T): value is R;\n and?: (criteria: ComplexPredicate<T, R>) => ComplexPredicate<T, R>;\n };\n\nexport interface Traversable<T> {\n filter<R extends T = T>(by: ComplexPredicate<T, R>): R[];\n find<R extends T = T>(by: ComplexPredicate<T, R>): R | undefined;\n some(by: SimplePredicate<T>): boolean;\n}\n\n/**\n * A tree of source files. Eventually, it's a graph. Ideally, it's an acyclic directed graph.\n * Technically, it's implemented as a map-like collection with references between map entries.\n */\nexport class BuildGraph implements Traversable<Node> {\n readonly store: Map<string, Node>;\n private _watcher?: FSWatcher;\n\n constructor(store?: Map<string, Node>) {\n this.store = store ?? new Map<string, Node>();\n }\n\n get watcher(): FSWatcher | undefined {\n return this._watcher;\n }\n\n set watcher(watcher: FSWatcher | undefined) {\n this._watcher = watcher;\n }\n\n put(value: Node | Node[]) {\n if (value instanceof Array) {\n for (const node of value) {\n this.insert(node);\n }\n } else {\n this.insert(value);\n }\n\n return this;\n }\n\n private insert(node: Node) {\n if (this.store.has(node.url)) {\n // Clean up dependee references\n const oldNode = this.store.get(node.url);\n oldNode['_dependees'].delete(oldNode);\n }\n\n if (this.watcher) {\n const fileUrl = fileUrlPath(node.url);\n if (fileUrl) {\n this.watcher.add(fileUrl);\n }\n }\n\n this.store.set(node.url, node);\n }\n\n get(url: string): Node {\n return this.store.get(url);\n }\n\n has(url: string): boolean {\n return this.store.has(url);\n }\n\n entries(): Node[] {\n return Array.from(this.store.values());\n }\n\n values(): IterableIterator<Node> {\n return this.store.values();\n }\n\n some<T extends Node = Node>(by: ComplexPredicate<Node, T>): boolean {\n for (const node of this.store.values()) {\n if (by(node)) {\n return true;\n }\n }\n\n return false;\n }\n\n filter<T extends Node = Node>(by: ComplexPredicate<Node, T>): T[] {\n const result: T[] = [];\n\n for (const node of this.store.values()) {\n if (by(node)) {\n result.push(node as T);\n }\n }\n\n return result;\n }\n\n find<T extends Node = Node>(by: ComplexPredicate<Node, T>): T | undefined {\n for (const node of this.store.values()) {\n if (by(node)) {\n return node as T;\n }\n }\n\n return undefined;\n }\n\n get size(): number {\n return this.store.size;\n }\n}\n\nexport class ScopedBuildGraph<T extends Node = Node> extends BuildGraph {\n constructor(\n readonly parentGraph: BuildGraph,\n readonly activeEntryPoint: T,\n ) {\n super(parentGraph.store);\n }\n\n override get watcher(): FSWatcher | undefined {\n return this.parentGraph.watcher;\n }\n\n override set watcher(watcher: FSWatcher | undefined) {\n this.parentGraph.watcher = watcher;\n }\n}\n\nexport function isScopedBuildGraph<T extends Node = Node>(graph: BuildGraph): graph is ScopedBuildGraph<T> {\n return graph instanceof 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C;gBACb,OAAO,IAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AAjGD,gCAiGC;AAED,MAAa,gBAAwC,SAAQ,UAAU;IAE1D;IACA;IACS;IAHpB,YACW,WAAuB,EACvB,gBAAmB,EACV,aAAa,KAAK;QAEpC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAJhB,gBAAW,GAAX,WAAW,CAAY;QACvB,qBAAgB,GAAhB,gBAAgB,CAAG;QACV,eAAU,GAAV,UAAU,CAAQ;IAGtC,CAAC;IAED,IAAa,OAAO;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,IAAa,OAAO,CAAC,OAA8B;QACjD,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;IACrC,CAAC;CACF;AAhBD,4CAgBC;AAED,SAAgB,kBAAkB,CAAwB,KAAiB;IACzE,OAAO,KAAK,YAAY,gBAAgB,CAAC;AAC3C,CAAC","sourcesContent":["import { FSWatcher } from 'chokidar';\nimport { fileUrlPath } from '../ng-package/nodes';\nimport { Node } from './node';\n\nexport type SimplePredicate<T = Node> = {\n (value: T): boolean;\n and?: (criteria: SimplePredicate<T>) => SimplePredicate<T>;\n};\n\nexport type ComplexPredicate<T = Node, R extends T = T> =\n | SimplePredicate<T>\n | {\n (value: T): value is R;\n and?: (criteria: ComplexPredicate<T, R>) => ComplexPredicate<T, R>;\n };\n\nexport interface Traversable<T> {\n filter<R extends T = T>(by: ComplexPredicate<T, R>): R[];\n find<R extends T = T>(by: ComplexPredicate<T, R>): R | undefined;\n some(by: SimplePredicate<T>): boolean;\n}\n\n/**\n * A tree of source files. Eventually, it's a graph. Ideally, it's an acyclic directed graph.\n * Technically, it's implemented as a map-like collection with references between map entries.\n */\nexport class BuildGraph implements Traversable<Node> {\n readonly isParallel: boolean = false;\n readonly store: Map<string, Node>;\n private _watcher?: FSWatcher;\n\n constructor(store?: Map<string, Node>) {\n this.store = store ?? new Map<string, Node>();\n }\n\n get watcher(): FSWatcher | undefined {\n return this._watcher;\n }\n\n set watcher(watcher: FSWatcher | undefined) {\n this._watcher = watcher;\n }\n\n put(value: Node | Node[]) {\n if (value instanceof Array) {\n for (const node of value) {\n this.insert(node);\n }\n } else {\n this.insert(value);\n }\n\n return this;\n }\n\n private insert(node: Node) {\n if (this.store.has(node.url)) {\n // Clean up dependee references\n const oldNode = this.store.get(node.url);\n oldNode['_dependees'].delete(oldNode);\n }\n\n if (this.watcher) {\n const fileUrl = fileUrlPath(node.url);\n if (fileUrl) {\n this.watcher.add(fileUrl);\n }\n }\n\n this.store.set(node.url, node);\n }\n\n get(url: string): Node {\n return this.store.get(url);\n }\n\n has(url: string): boolean {\n return this.store.has(url);\n }\n\n entries(): Node[] {\n return Array.from(this.store.values());\n }\n\n values(): IterableIterator<Node> {\n return this.store.values();\n }\n\n some<T extends Node = Node>(by: ComplexPredicate<Node, T>): boolean {\n for (const node of this.store.values()) {\n if (by(node)) {\n return true;\n }\n }\n\n return false;\n }\n\n filter<T extends Node = Node>(by: ComplexPredicate<Node, T>): T[] {\n const result: T[] = [];\n\n for (const node of this.store.values()) {\n if (by(node)) {\n result.push(node as T);\n }\n }\n\n return result;\n }\n\n find<T extends Node = Node>(by: ComplexPredicate<Node, T>): T | undefined {\n for (const node of this.store.values()) {\n if (by(node)) {\n return node as T;\n }\n }\n\n return undefined;\n }\n\n get size(): number {\n return this.store.size;\n }\n}\n\nexport class ScopedBuildGraph<T extends Node = Node> extends BuildGraph {\n constructor(\n readonly parentGraph: BuildGraph,\n readonly activeEntryPoint: T,\n override readonly isParallel = false,\n ) {\n super(parentGraph.store);\n }\n\n override get watcher(): FSWatcher | undefined {\n return this.parentGraph.watcher;\n }\n\n override set watcher(watcher: FSWatcher | undefined) {\n this.parentGraph.watcher = watcher;\n }\n}\n\nexport function isScopedBuildGraph<T extends Node = Node>(graph: BuildGraph): graph is ScopedBuildGraph<T> {\n return graph instanceof ScopedBuildGraph;\n}\n"]}
@@ -5,18 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.compileNgcTransformFactory = void 0;
7
7
  const node_path_1 = require("node:path");
8
- const ora_1 = __importDefault(require("ora"));
9
8
  const typescript_1 = __importDefault(require("typescript"));
10
9
  const transform_1 = require("../../graph/transform");
11
10
  const compile_source_files_1 = require("../../ngc/compile-source-files");
12
11
  const tsconfig_1 = require("../../ts/tsconfig");
12
+ const spinner_1 = require("../../utils/spinner");
13
13
  const nodes_1 = require("../nodes");
14
14
  const compileNgcTransformFactory = (StylesheetProcessor, options) => {
15
15
  return (0, transform_1.transformFromPromise)(async (graph) => {
16
- const spinner = (0, ora_1.default)({
17
- hideCursor: false,
18
- discardStdin: false,
19
- });
16
+ const spinner = (0, spinner_1.openSpinner)(undefined, graph);
20
17
  const entryPoints = graph.filter(nodes_1.isEntryPoint);
21
18
  const ngPackageNode = (0, nodes_1.findPackageNode)(graph);
22
19
  const entryPoint = (0, nodes_1.getActiveEntryPoint)(graph);
@@ -1 +1 @@
1
- {"version":3,"file":"compile-ngc.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/compile-ngc.transform.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,8CAAsB;AACtB,4DAA4B;AAC5B,qDAAwE;AACxE,yEAAoE;AAEpE,gDAAiE;AACjE,oCAA8E;AAGvE,MAAM,0BAA0B,GAAG,CACxC,mBAAoD,EACpD,OAAyB,EACd,EAAE;IACb,OAAO,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;QACxC,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;YAClB,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QA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,MAAM;aAC/B,EACD,UAAU,CAAC,KAAK,CAAC,mBAAmB,CACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA5DW,QAAA,0BAA0B,8BA4DrC","sourcesContent":["import { dirname } from 'node:path';\nimport ora from 'ora';\nimport ts from 'typescript';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { compileSourceFiles } from '../../ngc/compile-source-files';\nimport { StylesheetProcessor as StylesheetProcessorClass } from '../../styles/stylesheet-processor';\nimport { setDependenciesTsConfigPaths } from '../../ts/tsconfig';\nimport { findPackageNode, getActiveEntryPoint, isEntryPoint } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\nexport const compileNgcTransformFactory = (\n StylesheetProcessor: typeof StylesheetProcessorClass,\n options: NgPackagrOptions,\n): Transform => {\n return transformFromPromise(async graph => {\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const entryPoints = graph.filter(isEntryPoint);\n const ngPackageNode = findPackageNode(graph);\n const entryPoint = getActiveEntryPoint(graph);\n const projectBasePath = ngPackageNode.data.primary.basePath;\n\n try {\n // Add paths mappings for dependencies\n const tsConfig = setDependenciesTsConfigPaths(entryPoint.data.tsConfig, entryPoints);\n\n // Compile TypeScript sources\n const { esm2022, declarations } = entryPoint.data.destinationFiles;\n const { basePath, cssUrl, styleIncludePaths, sass } = entryPoint.data.entryPoint;\n const { moduleResolutionCache } = entryPoint.cache;\n\n spinner.start(\n `Compiling with Angular sources in ${tsConfig.options.compilationMode || 'full'} compilation mode.`,\n );\n\n entryPoint.cache.stylesheetProcessor ??= new StylesheetProcessor(\n projectBasePath,\n basePath,\n cssUrl,\n styleIncludePaths,\n sass,\n options.cacheEnabled && options.cacheDirectory,\n options.watch,\n );\n\n await compileSourceFiles(\n graph,\n tsConfig,\n moduleResolutionCache,\n options,\n {\n outDir: dirname(esm2022),\n declarationDir: dirname(declarations),\n declaration: true,\n target: ts.ScriptTarget.ES2022,\n },\n entryPoint.cache.stylesheetProcessor,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n spinner.succeed();\n\n return graph;\n });\n};\n"]}
1
+ {"version":3,"file":"compile-ngc.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/compile-ngc.transform.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,4DAA4B;AAC5B,qDAAwE;AACxE,yEAAoE;AAEpE,gDAAiE;AACjE,iDAAkD;AAClD,oCAA8E;AAGvE,MAAM,0BAA0B,GAAG,CACxC,mBAAoD,EACpD,OAAyB,EACd,EAAE;IACb,OAAO,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;QACxC,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAE9C,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;QAC/C,MAAM,aAAa,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;QAC7C,MAAM,UAAU,GAAG,IAAA,2BAAmB,EAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAE5D,IAAI,CAAC;YACH,sCAAsC;YACtC,MAAM,QAAQ,GAAG,IAAA,uCAA4B,EAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAErF,6BAA6B;YAC7B,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC;YACnE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;YACjF,MAAM,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC;YAEnD,OAAO,CAAC,KAAK,CACX,qCAAqC,QAAQ,CAAC,OAAO,CAAC,eAAe,IAAI,MAAM,oBAAoB,CACpG,CAAC;YAEF,UAAU,CAAC,KAAK,CAAC,mBAAmB,KAAK,IAAI,mBAAmB,CAC9D,eAAe,EACf,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,IAAI,EACJ,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,cAAc,EAC9C,OAAO,CAAC,KAAK,CACd,CAAC;YAEF,MAAM,IAAA,yCAAkB,EACtB,KAAK,EACL,QAAQ,EACR,qBAAqB,EACrB,OAAO,EACP;gBACE,MAAM,EAAE,IAAA,mBAAO,EAAC,OAAO,CAAC;gBACxB,cAAc,EAAE,IAAA,mBAAO,EAAC,YAAY,CAAC;gBACrC,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;aAC/B,EACD,UAAU,CAAC,KAAK,CAAC,mBAAmB,CACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAzDW,QAAA,0BAA0B,8BAyDrC","sourcesContent":["import { dirname } from 'node:path';\nimport ts from 'typescript';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { compileSourceFiles } from '../../ngc/compile-source-files';\nimport { StylesheetProcessor as StylesheetProcessorClass } from '../../styles/stylesheet-processor';\nimport { setDependenciesTsConfigPaths } from '../../ts/tsconfig';\nimport { openSpinner } from '../../utils/spinner';\nimport { findPackageNode, getActiveEntryPoint, isEntryPoint } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\nexport const compileNgcTransformFactory = (\n StylesheetProcessor: typeof StylesheetProcessorClass,\n options: NgPackagrOptions,\n): Transform => {\n return transformFromPromise(async graph => {\n const spinner = openSpinner(undefined, graph);\n\n const entryPoints = graph.filter(isEntryPoint);\n const ngPackageNode = findPackageNode(graph);\n const entryPoint = getActiveEntryPoint(graph);\n const projectBasePath = ngPackageNode.data.primary.basePath;\n\n try {\n // Add paths mappings for dependencies\n const tsConfig = setDependenciesTsConfigPaths(entryPoint.data.tsConfig, entryPoints);\n\n // Compile TypeScript sources\n const { esm2022, declarations } = entryPoint.data.destinationFiles;\n const { basePath, cssUrl, styleIncludePaths, sass } = entryPoint.data.entryPoint;\n const { moduleResolutionCache } = entryPoint.cache;\n\n spinner.start(\n `Compiling with Angular sources in ${tsConfig.options.compilationMode || 'full'} compilation mode.`,\n );\n\n entryPoint.cache.stylesheetProcessor ??= new StylesheetProcessor(\n projectBasePath,\n basePath,\n cssUrl,\n styleIncludePaths,\n sass,\n options.cacheEnabled && options.cacheDirectory,\n options.watch,\n );\n\n await compileSourceFiles(\n graph,\n tsConfig,\n moduleResolutionCache,\n options,\n {\n outDir: dirname(esm2022),\n declarationDir: dirname(declarations),\n declaration: true,\n target: ts.ScriptTarget.ES2022,\n },\n entryPoint.cache.stylesheetProcessor,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n spinner.succeed();\n\n return graph;\n });\n};\n"]}
@@ -1,27 +1,21 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.writeBundlesTransform = void 0;
7
4
  const node_path_1 = require("node:path");
8
- const ora_1 = __importDefault(require("ora"));
9
5
  const file_watcher_1 = require("../../file-system/file-watcher");
10
6
  const rolldown_1 = require("../../flatten/rolldown");
11
7
  const transform_1 = require("../../graph/transform");
12
8
  const cache_1 = require("../../utils/cache");
13
9
  const fs_1 = require("../../utils/fs");
14
10
  const path_1 = require("../../utils/path");
11
+ const spinner_1 = require("../../utils/spinner");
15
12
  const nodes_1 = require("../nodes");
16
13
  const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)(async (graph) => {
17
14
  const entryPoint = (0, nodes_1.getActiveEntryPoint)(graph);
18
15
  const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;
19
16
  const cache = entryPoint.cache;
20
17
  const { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;
21
- const spinner = (0, ora_1.default)({
22
- hideCursor: false,
23
- discardStdin: false,
24
- });
18
+ const spinner = (0, spinner_1.openSpinner)(undefined, graph);
25
19
  const cacheKey = await (0, cache_1.generateKey)(ngEntryPoint.moduleId, declarationsDir, fesm2022Dir, tsConfig.options.compilationMode, (tsConfig.options.declarationMap ?? false).toString());
26
20
  const hash = await (0, cache_1.generateKey)([...cache.outputCache.entries()]
27
21
  .sort(([a], [b]) => a.localeCompare(b))
@@ -1 +1 @@
1
- {"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAiC;AACjC,8CAAsB;AAEtB,iEAA2F;AAC3F,qDAA4D;AAC5D,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,2CAAkD;AAClD,oCAA+C;AAqBxC,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,UAAU,GAAG,IAAA,2BAAmB,EAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IA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nimport ora from 'ora';\nimport type { OutputAsset, OutputChunk } from 'rolldown';\nimport { invalidateEntryPointsAndCacheOnFileChange } from '../../file-system/file-watcher';\nimport { rolldownBundleFile } from '../../flatten/rolldown';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { exists, mkdir, writeFile } from '../../utils/fs';\nimport { ensureUnixPath } from '../../utils/path';\nimport { getActiveEntryPoint } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ntype CachedBundleFile =\n | {\n type: 'chunk';\n fileName: string;\n code: string;\n }\n | {\n type: 'asset';\n fileName: string;\n source: string | Uint8Array;\n };\n\ninterface BundlesCache {\n hash: string;\n fesm2022: CachedBundleFile[];\n types: CachedBundleFile[];\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint = getActiveEntryPoint(graph);\n const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const cacheKey = await generateKey(\n ngEntryPoint.moduleId,\n declarationsDir,\n fesm2022Dir,\n tsConfig.options.compilationMode,\n (tsConfig.options.declarationMap ?? false).toString(),\n );\n const hash = await generateKey(\n [...cache.outputCache.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([p, { version }]) => `${p}:${version}`)\n .join(':'),\n );\n const cacheDirectory = options.cacheEnabled && options.cacheDirectory;\n if (cacheDirectory) {\n const cacheResult: BundlesCache = await readCacheEntry(options.cacheDirectory, cacheKey);\n if (cacheResult?.hash === hash) {\n const filesToCopy = [\n ...cacheResult.fesm2022.map(file => ({\n ...file,\n filePath: join(fesm2022Dir, file.fileName),\n })),\n ...cacheResult.types.map(file => ({\n ...file,\n filePath: join(declarationsDir, file.fileName),\n })),\n ];\n\n try {\n const writeFilePromises: Promise<void>[] = [];\n for (const file of filesToCopy) {\n if (options.watch && (await exists(file.filePath))) {\n continue;\n }\n\n if (writeFilePromises.length === 0) {\n spinner.start('Writing FESM and DTS bundles');\n await Promise.all([mkdir(fesm2022Dir, { recursive: true }), mkdir(declarationsDir, { recursive: true })]);\n }\n\n writeFilePromises.push(writeFile(file.filePath, file.type === 'asset' ? file.source : file.code));\n }\n\n if (writeFilePromises.length) {\n await Promise.all(writeFilePromises);\n spinner.succeed('Writing FESM and DTS bundles');\n }\n } catch (error) {\n spinner.fail('Writing FESM and DTS bundles');\n throw error;\n }\n\n return;\n }\n }\n\n async function generateBundles(): Promise<BundlesCache> {\n const [{ files: fesmFiles }, { files: typesFiles }] = await Promise.all([\n rolldownBundleFile({\n entry: esm2022,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: fesm2022Dir,\n fileCache: cache.outputCache,\n sourcemap: true,\n }),\n rolldownBundleFile({\n entry: declarations,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: declarationsDir,\n fileCache: cache.outputCache,\n sourcemap: tsConfig.options.declarationMap ?? false,\n }),\n ]);\n\n const mapFile = (file: OutputChunk | OutputAsset): CachedBundleFile =>\n file.type === 'chunk'\n ? {\n type: 'chunk',\n fileName: file.fileName,\n code: file.code,\n }\n : {\n type: 'asset',\n fileName: file.fileName,\n source: file.source,\n };\n\n return {\n hash,\n types: typesFiles.map(mapFile),\n fesm2022: fesmFiles.map(mapFile),\n };\n }\n\n let bundlesCache: BundlesCache;\n try {\n bundlesCache = await generateBundles();\n spinner.succeed('Generating FESM and DTS bundles');\n\n // Invalidate dependent entry-points\n const changedDtsFiles: string[] = [];\n for (const file of bundlesCache.types) {\n if (file.type !== 'chunk' || !file.fileName.endsWith('.d.ts')) {\n continue;\n }\n\n const dtsFile = ensureUnixPath(join(declarationsDir, file.fileName));\n const cachedSourceFile = cache.sourcesFileCache.get(dtsFile);\n if (cachedSourceFile?.sourceFile?.text !== file.code) {\n changedDtsFiles.push(dtsFile);\n }\n }\n\n if (changedDtsFiles.length) {\n invalidateEntryPointsAndCacheOnFileChange(graph, changedDtsFiles, cache.sourcesFileCache);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, cacheKey, bundlesCache);\n }\n });\n"]}
1
+ {"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAEjC,iEAA2F;AAC3F,qDAA4D;AAC5D,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,2CAAkD;AAClD,iDAAkD;AAClD,oCAA+C;AAqBxC,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,UAAU,GAAG,IAAA,2BAAmB,EAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,gBAAgB,CAAC;IACjF,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAE9C,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAW,EAChC,YAAY,CAAC,QAAQ,EACrB,eAAe,EACf,WAAW,EACX,QAAQ,CAAC,OAAO,CAAC,eAAe,EAChC,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,IAAI,KAAK,CAAC,CAAC,QAAQ,EAAE,CACtD,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,IAAA,mBAAW,EAC5B,C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AA,qBAAc,EAAC,IAAA,gBAAI,EAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrE,MAAM,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7D,IAAI,gBAAgB,EAAE,UAAU,EAAE,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACrD,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAED,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;YAC3B,IAAA,wDAAyC,EAAC,KAAK,EAAE,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACd,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC,CAAC;AAtIQ,QAAA,qBAAqB,yBAsI7B","sourcesContent":["import { join } from 'node:path';\nimport type { OutputAsset, OutputChunk } from 'rolldown';\nimport { invalidateEntryPointsAndCacheOnFileChange } from '../../file-system/file-watcher';\nimport { rolldownBundleFile } from '../../flatten/rolldown';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { exists, mkdir, writeFile } from '../../utils/fs';\nimport { ensureUnixPath } from '../../utils/path';\nimport { openSpinner } from '../../utils/spinner';\nimport { getActiveEntryPoint } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ntype CachedBundleFile =\n | {\n type: 'chunk';\n fileName: string;\n code: string;\n }\n | {\n type: 'asset';\n fileName: string;\n source: string | Uint8Array;\n };\n\ninterface BundlesCache {\n hash: string;\n fesm2022: CachedBundleFile[];\n types: CachedBundleFile[];\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint = getActiveEntryPoint(graph);\n const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;\n const spinner = openSpinner(undefined, graph);\n\n const cacheKey = await generateKey(\n ngEntryPoint.moduleId,\n declarationsDir,\n fesm2022Dir,\n tsConfig.options.compilationMode,\n (tsConfig.options.declarationMap ?? false).toString(),\n );\n const hash = await generateKey(\n [...cache.outputCache.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([p, { version }]) => `${p}:${version}`)\n .join(':'),\n );\n const cacheDirectory = options.cacheEnabled && options.cacheDirectory;\n if (cacheDirectory) {\n const cacheResult: BundlesCache = await readCacheEntry(options.cacheDirectory, cacheKey);\n if (cacheResult?.hash === hash) {\n const filesToCopy = [\n ...cacheResult.fesm2022.map(file => ({\n ...file,\n filePath: join(fesm2022Dir, file.fileName),\n })),\n ...cacheResult.types.map(file => ({\n ...file,\n filePath: join(declarationsDir, file.fileName),\n })),\n ];\n\n try {\n const writeFilePromises: Promise<void>[] = [];\n for (const file of filesToCopy) {\n if (options.watch && (await exists(file.filePath))) {\n continue;\n }\n\n if (writeFilePromises.length === 0) {\n spinner.start('Writing FESM and DTS bundles');\n await Promise.all([mkdir(fesm2022Dir, { recursive: true }), mkdir(declarationsDir, { recursive: true })]);\n }\n\n writeFilePromises.push(writeFile(file.filePath, file.type === 'asset' ? file.source : file.code));\n }\n\n if (writeFilePromises.length) {\n await Promise.all(writeFilePromises);\n spinner.succeed('Writing FESM and DTS bundles');\n }\n } catch (error) {\n spinner.fail('Writing FESM and DTS bundles');\n throw error;\n }\n\n return;\n }\n }\n\n async function generateBundles(): Promise<BundlesCache> {\n const [{ files: fesmFiles }, { files: typesFiles }] = await Promise.all([\n rolldownBundleFile({\n entry: esm2022,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: fesm2022Dir,\n fileCache: cache.outputCache,\n sourcemap: true,\n }),\n rolldownBundleFile({\n entry: declarations,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: declarationsDir,\n fileCache: cache.outputCache,\n sourcemap: tsConfig.options.declarationMap ?? false,\n }),\n ]);\n\n const mapFile = (file: OutputChunk | OutputAsset): CachedBundleFile =>\n file.type === 'chunk'\n ? {\n type: 'chunk',\n fileName: file.fileName,\n code: file.code,\n }\n : {\n type: 'asset',\n fileName: file.fileName,\n source: file.source,\n };\n\n return {\n hash,\n types: typesFiles.map(mapFile),\n fesm2022: fesmFiles.map(mapFile),\n };\n }\n\n let bundlesCache: BundlesCache;\n try {\n bundlesCache = await generateBundles();\n spinner.succeed('Generating FESM and DTS bundles');\n\n // Invalidate dependent entry-points\n const changedDtsFiles: string[] = [];\n for (const file of bundlesCache.types) {\n if (file.type !== 'chunk' || !file.fileName.endsWith('.d.ts')) {\n continue;\n }\n\n const dtsFile = ensureUnixPath(join(declarationsDir, file.fileName));\n const cachedSourceFile = cache.sourcesFileCache.get(dtsFile);\n if (cachedSourceFile?.sourceFile?.text !== file.code) {\n changedDtsFiles.push(dtsFile);\n }\n }\n\n if (changedDtsFiles.length) {\n invalidateEntryPointsAndCacheOnFileChange(graph, changedDtsFiles, cache.sourcesFileCache);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, cacheKey, bundlesCache);\n }\n });\n"]}
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.writePackageTransform = void 0;
7
7
  const node_path_1 = require("node:path");
8
- const ora_1 = __importDefault(require("ora"));
9
8
  const tinyglobby_1 = require("tinyglobby");
10
9
  const node_1 = require("../../graph/node");
11
10
  const transform_1 = require("../../graph/transform");
@@ -14,9 +13,10 @@ const fs_1 = require("../../utils/fs");
14
13
  const log_1 = __importDefault(require("../../utils/log"));
15
14
  const package_json_1 = require("../../utils/package-json");
16
15
  const path_1 = require("../../utils/path");
16
+ const spinner_1 = require("../../utils/spinner");
17
17
  const nodes_1 = require("../nodes");
18
18
  const writePackageTransform = (options) => (0, transform_1.transformFromPromise)(async (graph) => {
19
- const spinner = (0, ora_1.default)({ hideCursor: false, discardStdin: false });
19
+ const spinner = (0, spinner_1.openSpinner)(undefined, graph);
20
20
  const entryPoints = graph.filter(nodes_1.isEntryPoint);
21
21
  const entryPoint = (0, nodes_1.getActiveEntryPoint)(graph);
22
22
  const ngEntryPoint = entryPoint.data.entryPoint;
@@ -1 +1 @@
1
- {"version":3,"file":"write-package.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;;;;AAAA,yCAA8D;AAC9D,8CAAoC;AACpC,2CAAkC;AAGlC,2CAAwC;AACxC,qDAA6D;AAC7D,6CAA2C;AAC3C,uCAAyE;AACzE,0DAAkC;AAClC,2DAA2G;AAC3G,2CAAkD;AAClD,oCAAoH;AAO7G,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,IAAA,2BAAmB,EAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,YAAY,GAAiB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9D,MAAM,aAAa,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG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4EAA4E,CAAC,CAAC;QACjH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { basename, dirname, join, relative } from 'node:path';\nimport ora, { type Ora } from 'ora';\nimport { glob } from 'tinyglobby';\nimport { AssetPattern } from '../../../ng-package.schema';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Node } from '../../graph/node';\nimport { transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { copyFile, mkdir, rmdir, stat, writeFile } from '../../utils/fs';\nimport log from '../../utils/log';\nimport { ConditionalExport, generatePackageExports, generateWatchVersion } from '../../utils/package-json';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, PackageNode, fileUrl, findPackageNode, getActiveEntryPoint, isEntryPoint } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\nimport { NgPackage } from '../package';\nimport { NgEntryPoint } from './entry-point';\n\ntype CompilationMode = 'partial' | 'full' | undefined;\n\nexport const writePackageTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const spinner = ora({ hideCursor: false, discardStdin: false });\n const entryPoints = graph.filter(isEntryPoint);\n const entryPoint = getActiveEntryPoint(graph);\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode = findPackageNode(graph);\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n spinner.start('Copying assets');\n try {\n await copyAssets(graph, entryPoint, ngPackageNode, entryPoints);\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(relative(ngEntryPoint.destinationPath, filePath));\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n try {\n spinner.start('Writing package manifest');\n if (!options.watch) {\n const primary = ngPackageNode.data.primary;\n\n const nestedPackageJsons: string[] = [];\n // Secondary entry-points package.json\n for (const { data } of entryPoints) {\n if (!data.entryPoint.isSecondaryEntryPoint) {\n continue;\n }\n\n const packageJsonPath = ensureUnixPath(\n join(relative(primary.destinationPath, data.entryPoint.destinationPath), 'package.json'),\n );\n nestedPackageJsons.push(packageJsonPath);\n }\n\n if (nestedPackageJsons.length) {\n await writeFile(\n join(primary.destinationPath, '.npmignore'),\n `# Nested package.json's are only needed for development.\\n${nestedPackageJsons.join('\\n')}`,\n );\n }\n }\n\n const { compilationMode } = entryPoint.data.tsConfig.options;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n module: relativeUnixFromDestPath(destinationFiles.fesm2022),\n typings: relativeUnixFromDestPath(destinationFiles.declarationsBundled),\n exports: generatePackageExports(ngEntryPoint, entryPoints),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.packageJson.sideEffects ?? false,\n },\n !!options.watch,\n compilationMode as CompilationMode,\n spinner,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n } else if (ngEntryPoint.isSecondaryEntryPoint) {\n // Write a package.json in each secondary entry-point\n // This is need for esbuild to secondary entry-points in dist correctly.\n await mkdir(ngEntryPoint.destinationPath, { recursive: true });\n await writeFile(\n join(ngEntryPoint.destinationPath, 'package.json'),\n JSON.stringify(\n {\n module: relativeUnixFromDestPath(destinationFiles.fesm2022),\n typings: relativeUnixFromDestPath(destinationFiles.declarationsBundled),\n },\n undefined,\n 2,\n ),\n );\n }\n\n spinner.succeed(`Built ${ngEntryPoint.moduleId}`);\n });\n\ntype AssetEntry = Exclude<AssetPattern, string>;\n\nasync function copyAssets(\n graph: BuildGraph,\n entryPointNode: EntryPointNode,\n ngPackageNode: PackageNode,\n entryPoints: EntryPointNode[],\n): Promise<void> {\n const ngPackage = ngPackageNode.data;\n const globsForceIgnored: string[] = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db', `${ngPackage.dest}/**`];\n const defaultAssets: AssetEntry[] = [\n { glob: 'LICENSE', input: '/', output: '/' },\n ...entryPoints.map(({ data }) => {\n const subpath = data.entryPoint.destinationFiles.directory || '/';\n\n return { glob: 'README.md', input: subpath, output: subpath };\n }),\n ];\n\n const assets: AssetEntry[] = [];\n for (const assetPath of [...ngPackage.assets, ...defaultAssets]) {\n let asset: AssetEntry;\n if (typeof assetPath === 'object') {\n asset = { ...assetPath };\n } else {\n const [isDir, isFile] = await stat(join(ngPackage.src, assetPath))\n .then(stats => [stats.isDirectory(), stats.isFile()])\n .catch(() => [false, false]);\n if (isDir) {\n asset = { glob: '**/*', input: assetPath, output: assetPath };\n } else if (isFile) {\n // filenames are their own glob\n asset = { glob: basename(assetPath), input: dirname(assetPath), output: dirname(assetPath) };\n } else {\n asset = { glob: assetPath, input: '/', output: '/' };\n }\n }\n\n asset.input = join(ngPackage.src, asset.input);\n asset.output = join(ngPackage.dest, asset.output);\n\n const isAncestorPath = (target: string, datum: string) => relative(datum, target).startsWith('..');\n if (isAncestorPath(asset.input, ngPackage.src)) {\n throw new Error('Cannot read assets from a location outside of the project root.');\n }\n if (isAncestorPath(asset.output, ngPackage.dest)) {\n throw new Error('Cannot write assets to a location outside of the output path.');\n }\n\n assets.push(asset);\n }\n\n for (const asset of assets) {\n const filePaths = await glob(asset.glob, {\n cwd: asset.input,\n ignore: [...(asset.ignore ?? []), ...globsForceIgnored],\n dot: true,\n onlyFiles: true,\n followSymbolicLinks: asset.followSymlinks,\n });\n for (const filePath of filePaths) {\n const fileSrcFullPath = join(asset.input, filePath);\n const fileDestFullPath = join(asset.output, filePath);\n const nodeUri = fileUrl(ensureUnixPath(fileSrcFullPath));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n entryPointNode.dependsOn(node);\n await copyFile(fileSrcFullPath, fileDestFullPath);\n }\n }\n}\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] | ConditionalExport },\n isWatchMode: boolean,\n compilationMode: CompilationMode,\n spinner: Ora,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n packageJson.type ??= 'module';\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (isWatchMode) {\n // Needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/angular/angular-cli/issues/20962\n packageJson.version = generateWatchVersion();\n }\n\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = { ...packageJson.dependencies, tslib: tsLibVersion };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n spinner.warn(\n colors.yellow(\n `'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`,\n ),\n );\n packageJson.dependencies = { ...(packageJson.dependencies || {}), tslib: packageJson.peerDependencies.tslib };\n\n delete packageJson.peerDependencies.tslib;\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const allowedList = pkg.allowedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', allowedList, spinner);\n } catch (e) {\n await rmdir(entryPoint.destinationPath, { recursive: true });\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n spinner.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n spinner.warn(\n colors.yellow(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n ),\n );\n }\n }\n\n if (compilationMode !== 'partial') {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled in full compilation mode. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package with partial compilation mode, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n spinner.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n await writeFile(join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n}\n\nfunction checkNonPeerDependencies(\n packageJson: Record<string, unknown>,\n property: string,\n allowed: RegExp[],\n spinner: Ora,\n) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (allowed.some(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is allowed in '${property}'`);\n } else {\n spinner.warn(\n colors.yellow(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep} ` +\n `to 'peerDependencies' or remove it from '${property}'.`,\n ),\n );\n throw new Error(`Dependency ${dep} must be explicitly allowed using the \"allowedNonPeerDependencies\" option.`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"write-package.transform.js","sourceRoot":"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,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/G,CAAC;AAED,SAAS,wBAAwB,CAC/B,WAAoC,EACpC,QAAgB,EAChB,OAAiB,EACjB,OAAY;IAEZ,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC3C,aAAG,CAAC,KAAK,CAAC,cAAc,GAAG,mBAAmB,QAAQ,GAAG,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CACV,cAAM,CAAC,MAAM,CACX,mCAAmC,QAAQ,gDAAgD,GAAG,GAAG;gBAC/F,4CAA4C,QAAQ,IAAI,CAC3D,CACF,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,4EAA4E,CAAC,CAAC;QACjH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { basename, dirname, join, relative } from 'node:path';\nimport type { Ora } from 'ora';\nimport { glob } from 'tinyglobby';\nimport { AssetPattern } from '../../../ng-package.schema';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Node } from '../../graph/node';\nimport { transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { copyFile, mkdir, rmdir, stat, writeFile } from '../../utils/fs';\nimport log from '../../utils/log';\nimport { ConditionalExport, generatePackageExports, generateWatchVersion } from '../../utils/package-json';\nimport { ensureUnixPath } from '../../utils/path';\nimport { openSpinner } from '../../utils/spinner';\nimport { EntryPointNode, PackageNode, fileUrl, findPackageNode, getActiveEntryPoint, isEntryPoint } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\nimport { NgPackage } from '../package';\nimport { NgEntryPoint } from './entry-point';\n\ntype CompilationMode = 'partial' | 'full' | undefined;\n\nexport const writePackageTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const spinner = openSpinner(undefined, graph);\n const entryPoints = graph.filter(isEntryPoint);\n const entryPoint = getActiveEntryPoint(graph);\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode = findPackageNode(graph);\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n spinner.start('Copying assets');\n try {\n await copyAssets(graph, entryPoint, ngPackageNode, entryPoints);\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(relative(ngEntryPoint.destinationPath, filePath));\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n try {\n spinner.start('Writing package manifest');\n if (!options.watch) {\n const primary = ngPackageNode.data.primary;\n\n const nestedPackageJsons: string[] = [];\n // Secondary entry-points package.json\n for (const { data } of entryPoints) {\n if (!data.entryPoint.isSecondaryEntryPoint) {\n continue;\n }\n\n const packageJsonPath = ensureUnixPath(\n join(relative(primary.destinationPath, data.entryPoint.destinationPath), 'package.json'),\n );\n nestedPackageJsons.push(packageJsonPath);\n }\n\n if (nestedPackageJsons.length) {\n await writeFile(\n join(primary.destinationPath, '.npmignore'),\n `# Nested package.json's are only needed for development.\\n${nestedPackageJsons.join('\\n')}`,\n );\n }\n }\n\n const { compilationMode } = entryPoint.data.tsConfig.options;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n module: relativeUnixFromDestPath(destinationFiles.fesm2022),\n typings: relativeUnixFromDestPath(destinationFiles.declarationsBundled),\n exports: generatePackageExports(ngEntryPoint, entryPoints),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.packageJson.sideEffects ?? false,\n },\n !!options.watch,\n compilationMode as CompilationMode,\n spinner,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n } else if (ngEntryPoint.isSecondaryEntryPoint) {\n // Write a package.json in each secondary entry-point\n // This is need for esbuild to secondary entry-points in dist correctly.\n await mkdir(ngEntryPoint.destinationPath, { recursive: true });\n await writeFile(\n join(ngEntryPoint.destinationPath, 'package.json'),\n JSON.stringify(\n {\n module: relativeUnixFromDestPath(destinationFiles.fesm2022),\n typings: relativeUnixFromDestPath(destinationFiles.declarationsBundled),\n },\n undefined,\n 2,\n ),\n );\n }\n\n spinner.succeed(`Built ${ngEntryPoint.moduleId}`);\n });\n\ntype AssetEntry = Exclude<AssetPattern, string>;\n\nasync function copyAssets(\n graph: BuildGraph,\n entryPointNode: EntryPointNode,\n ngPackageNode: PackageNode,\n entryPoints: EntryPointNode[],\n): Promise<void> {\n const ngPackage = ngPackageNode.data;\n const globsForceIgnored: string[] = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db', `${ngPackage.dest}/**`];\n const defaultAssets: AssetEntry[] = [\n { glob: 'LICENSE', input: '/', output: '/' },\n ...entryPoints.map(({ data }) => {\n const subpath = data.entryPoint.destinationFiles.directory || '/';\n\n return { glob: 'README.md', input: subpath, output: subpath };\n }),\n ];\n\n const assets: AssetEntry[] = [];\n for (const assetPath of [...ngPackage.assets, ...defaultAssets]) {\n let asset: AssetEntry;\n if (typeof assetPath === 'object') {\n asset = { ...assetPath };\n } else {\n const [isDir, isFile] = await stat(join(ngPackage.src, assetPath))\n .then(stats => [stats.isDirectory(), stats.isFile()])\n .catch(() => [false, false]);\n if (isDir) {\n asset = { glob: '**/*', input: assetPath, output: assetPath };\n } else if (isFile) {\n // filenames are their own glob\n asset = { glob: basename(assetPath), input: dirname(assetPath), output: dirname(assetPath) };\n } else {\n asset = { glob: assetPath, input: '/', output: '/' };\n }\n }\n\n asset.input = join(ngPackage.src, asset.input);\n asset.output = join(ngPackage.dest, asset.output);\n\n const isAncestorPath = (target: string, datum: string) => relative(datum, target).startsWith('..');\n if (isAncestorPath(asset.input, ngPackage.src)) {\n throw new Error('Cannot read assets from a location outside of the project root.');\n }\n if (isAncestorPath(asset.output, ngPackage.dest)) {\n throw new Error('Cannot write assets to a location outside of the output path.');\n }\n\n assets.push(asset);\n }\n\n for (const asset of assets) {\n const filePaths = await glob(asset.glob, {\n cwd: asset.input,\n ignore: [...(asset.ignore ?? []), ...globsForceIgnored],\n dot: true,\n onlyFiles: true,\n followSymbolicLinks: asset.followSymlinks,\n });\n for (const filePath of filePaths) {\n const fileSrcFullPath = join(asset.input, filePath);\n const fileDestFullPath = join(asset.output, filePath);\n const nodeUri = fileUrl(ensureUnixPath(fileSrcFullPath));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n entryPointNode.dependsOn(node);\n await copyFile(fileSrcFullPath, fileDestFullPath);\n }\n }\n}\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] | ConditionalExport },\n isWatchMode: boolean,\n compilationMode: CompilationMode,\n spinner: Ora,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n packageJson.type ??= 'module';\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (isWatchMode) {\n // Needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/angular/angular-cli/issues/20962\n packageJson.version = generateWatchVersion();\n }\n\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = { ...packageJson.dependencies, tslib: tsLibVersion };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n spinner.warn(\n colors.yellow(\n `'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`,\n ),\n );\n packageJson.dependencies = { ...(packageJson.dependencies || {}), tslib: packageJson.peerDependencies.tslib };\n\n delete packageJson.peerDependencies.tslib;\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const allowedList = pkg.allowedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', allowedList, spinner);\n } catch (e) {\n await rmdir(entryPoint.destinationPath, { recursive: true });\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n spinner.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n spinner.warn(\n colors.yellow(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n ),\n );\n }\n }\n\n if (compilationMode !== 'partial') {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled in full compilation mode. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package with partial compilation mode, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n spinner.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n await writeFile(join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n}\n\nfunction checkNonPeerDependencies(\n packageJson: Record<string, unknown>,\n property: string,\n allowed: RegExp[],\n spinner: Ora,\n) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (allowed.some(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is allowed in '${property}'`);\n } else {\n spinner.warn(\n colors.yellow(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep} ` +\n `to 'peerDependencies' or remove it from '${property}'.`,\n ),\n );\n throw new Error(`Dependency ${dep} must be explicitly allowed using the \"allowedNonPeerDependencies\" option.`);\n }\n }\n}\n"]}
@@ -161,6 +161,7 @@ const scheduleEntryPoints = (epTransform, options) => (0, rxjs_1.pipe)((0, rxjs_
161
161
  }
162
162
  }
163
163
  const maxConcurrency = Math.max(1, Math.min((0, node_os_1.availableParallelism)() - 1, 8));
164
+ const isParallel = maxConcurrency > 1 && pending.size > 1;
164
165
  let activeCount = 0;
165
166
  let buildError = null;
166
167
  let isCancelled = false;
@@ -215,7 +216,7 @@ const scheduleEntryPoints = (epTransform, options) => (0, rxjs_1.pipe)((0, rxjs_
215
216
  return;
216
217
  }
217
218
  activeCount++;
218
- const scopedGraph = new build_graph_1.ScopedBuildGraph(graph, ep);
219
+ const scopedGraph = new build_graph_1.ScopedBuildGraph(graph, ep, isParallel);
219
220
  const run$ = (0, rxjs_1.of)(scopedGraph).pipe((0, rxjs_1.tap)(() => {
220
221
  ep.state = node_1.STATE_IN_PROGRESS;
221
222
  }), epTransform, (0, rxjs_1.catchError)(err => {
@@ -1 +1 @@
1
- {"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/package.transform.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA4C;AAC5C,qCAA+C;AAC/C,+BAmBc;AACd,8DAAyG;AACzG,sDAAoE;AACpE,wCAAgG;AAEhG,uEAA6E;AAC7E,0CAAwC;AACxC,oCAAoC;AACpC,uDAA+B;AAC/B,2DAAuD;AACvD,mCAAiH;AAGjH;;;;;;;;;;;;;;;GAeG;AACI,MAAM,uBAAuB,GAClC,CACE,OAAe,EACf,OAAyB,EACzB,qBAAgC,EAChC,uBAAkC,EAClC,mBAA8B,EAC9B,EAAE,CACJ,CAAC,OAA+B,EAA0B,EAAE;IAC1D,aAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAErC,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK;QAClC,CAAC,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,CAAC;QACvF,CAAC,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,CAAC,CAAC;IAE1F,MAAM,MAAM,GAAG,IAAA,aAAK,EAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,mBAAW,CAAC,MAAM,CAAC,CAAC;IAEtC,OAAO,OAAO,CAAC,IAAI;IACjB,qCAAqC;IACrC,oFAAoF;IACpF,IAAA,gBAAS,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;QACtB,KAAK,CAAC,IAAI,GAAG,MAAM,IAAA,oCAAgB,EAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAEjD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjB,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;QAE5C,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC;gBACH,MA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E,CAAC;gCACpB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;4BACzB,CAAC;wBACH,CAAC;oBACH,CAAC;oBAED,IAAI,EAAE,CAAC;gBACT,CAAC;aACF,CAAC,CAAC;YAEH,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,EAAE,CAAC;IAEP,OAAO,GAAG,EAAE;QACV,WAAW,GAAG,IAAI,CAAC;QACnB,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QACtB,KAAK,MAAM,SAAS,IAAI,mBAAmB,EAAE,CAAC;YAC5C,SAAS,CAAC,WAAW,EAAE,CAAC;QAC1B,CAAC;QACD,mBAAmB,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC,CAAC,CACL,CACF,CAAC;AAEJ,SAAS,wBAAwB,CAAC,SAAe,EAAE,SAAiB;IAClE,aAAG,CAAC,OAAO,CAAC,kFAAkF,CAAC,CAAC;IAChG,aAAG,CAAC,OAAO,CAAC;UACJ,SAAS,CAAC,IAAI,CAAC,GAAG;UAClB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/B,aAAG,CAAC,OAAO,CAAC,gFAAgF,CAAC,CAAC;IAC9F,MAAM,CAAC,GAAG,cAAM,CAAC,IAAI,CAAC;IACtB,MAAM,CAAC,GAAG,cAAM,CAAC,KAAK,CAAC;IACvB,aAAG,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["import { DepGraph } from 'dependency-graph';\nimport { availableParallelism } from 'node:os';\nimport {\n EMPTY,\n NEVER,\n Observable,\n Subscription,\n catchError,\n concatMap,\n debounceTime,\n filter,\n finalize,\n last,\n map,\n of as observableOf,\n of,\n pipe,\n repeat,\n startWith,\n switchMap,\n tap,\n} from 'rxjs';\nimport { createFileWatch, invalidateEntryPointsAndCacheOnFileChange } from '../file-system/file-watcher';\nimport { BuildGraph, ScopedBuildGraph } from '../graph/build-graph';\nimport { Node, STATE_DONE, STATE_ERROR, STATE_IN_PROGRESS, STATE_PENDING } from '../graph/node';\nimport { Transform } from '../graph/transform';\nimport { shutdownSassWorkerPool } from '../styles/stylesheets/sass-language';\nimport { colors } from '../utils/color';\nimport { rmdir } from '../utils/fs';\nimport log from '../utils/log';\nimport { discoverPackages } from './discover-packages';\nimport { EntryPointNode, PackageNode, findPackageNode, isEntryPoint, isEntryPointPending, ngUrl } from './nodes';\nimport { NgPackagrOptions } from './options.di';\n\n/**\n * A transformation for building an npm package:\n *\n * - discoverPackages\n * - options\n * - initTsConfig\n * - analyzeTsSources (thereby extracting template and stylesheet files)\n * - for each entry point\n * - run the entryPontTransform\n *\n * @param project Project token, reference to `ng-package.json`\n * @param options ng-packagr options\n * @param initTsConfigTransform Transformation initializing the tsconfig of each entry point.\n * @param analyseSourcesTransform Transformation analyzing the typescript source files of each entry point.\n * @param entryPointTransform Transformation for asset rendering and compilation of a single entry point.\n */\nexport const packageTransformFactory =\n (\n project: string,\n options: NgPackagrOptions,\n initTsConfigTransform: Transform,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform,\n ) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n log.info(`Building Angular Package`);\n\n const buildTransform = options.watch\n ? watchTransformFactory(project, options, analyseSourcesTransform, entryPointTransform)\n : buildTransformFactory(project, options, analyseSourcesTransform, entryPointTransform);\n\n const pkgUri = ngUrl(project);\n const ngPkg = new PackageNode(pkgUri);\n\n return source$.pipe(\n // Discover packages and entry points\n // Clean the primary dest folder (should clean all secondary sub-directory, as well)\n switchMap(async graph => {\n ngPkg.data = await discoverPackages({ project });\n\n graph.put(ngPkg);\n const { dest, deleteDestPath } = ngPkg.data;\n\n if (deleteDestPath) {\n try {\n await rmdir(dest, { recursive: true });\n } catch {}\n }\n\n const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {\n const { destinationFiles, moduleId } = entryPoint;\n const node = new EntryPointNode(\n ngUrl(moduleId),\n ngPkg.cache.sourcesFileCache,\n ngPkg.cache.moduleResolutionCache,\n );\n node.data = { entryPoint, destinationFiles };\n node.state = STATE_PENDING;\n ngPkg.dependsOn(node);\n\n return node;\n });\n\n // Add entry points to graph\n return graph.put(entryPoints);\n }),\n // Initialize the tsconfig for each entry point\n initTsConfigTransform,\n // perform build\n buildTransform,\n finalize(() => {\n for (const node of ngPkg.dependents) {\n if (node instanceof EntryPointNode) {\n node.cache?.stylesheetProcessor?.destroy();\n }\n }\n shutdownSassWorkerPool();\n }),\n );\n };\n\nconst watchTransformFactory =\n (project: string, options: NgPackagrOptions, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const CompleteWaitingForFileChange = '\\nCompilation complete. Watching for file changes...';\n const FileChangeDetected = '\\nFile change detected. Starting incremental compilation...';\n const FailedWaitingForFileChange = '\\nCompilation failed. Watching for file changes...';\n\n return source$.pipe(\n switchMap(graph => {\n const {\n data,\n cache: { sourcesFileCache },\n } = findPackageNode(graph);\n const { onFileChange, watcher } = createFileWatch([], [data.dest + '/'], options.poll);\n graph.watcher = watcher;\n\n return onFileChange.pipe(\n map(fileChange => invalidateEntryPointsAndCacheOnFileChange(graph, [fileChange.filePath], sourcesFileCache)),\n filter(isChanged => isChanged),\n debounceTime(100),\n tap(() => log.msg(FileChangeDetected)),\n startWith(undefined),\n map(() => graph),\n );\n }),\n switchMap(graph => {\n const startTime = Date.now();\n const pkgUri = ngUrl(project);\n const ngPkg = graph.get(pkgUri);\n\n return observableOf(graph).pipe(\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform, options),\n repeat({ delay: () => (graph.some(isEntryPointPending()) ? of(1) : EMPTY) }),\n last(),\n tap(() => printBuiltAngularPackage(ngPkg, startTime)),\n catchError(error => {\n log.error(error);\n log.msg(FailedWaitingForFileChange);\n\n return NEVER;\n }),\n tap(() => log.msg(CompleteWaitingForFileChange)),\n );\n }),\n );\n };\n\nconst buildTransformFactory =\n (project: string, options: NgPackagrOptions, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n return source$.pipe(\n switchMap(graph => {\n const startTime = Date.now();\n const pkgUri = ngUrl(project);\n const ngPkg = graph.get(pkgUri);\n\n return observableOf(graph).pipe(\n // Analyse dependencies and external resources for each entry point\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform, options),\n tap(() => printBuiltAngularPackage(ngPkg, startTime)),\n );\n }),\n );\n };\n\nconst scheduleEntryPoints = (epTransform: Transform, options: NgPackagrOptions): Transform =>\n pipe(\n concatMap(\n graph =>\n new Observable<BuildGraph>(subscriber => {\n // Calculate node/dependency depth and determine build order\n const depGraph = new DepGraph({ circular: false });\n const entryPoints = new Map<string, EntryPointNode>();\n\n for (const node of graph.values()) {\n if (!isEntryPoint(node)) {\n continue;\n }\n\n // Remove `ng://` prefix for better error messages\n const from = node.url.startsWith('ng://') ? node.url.slice(5) : node.url;\n entryPoints.set(from, node);\n depGraph.addNode(from);\n\n for (const dep of node.dependents) {\n if (!isEntryPoint(dep)) {\n continue;\n }\n\n const to = dep.url.startsWith('ng://') ? dep.url.slice(5) : dep.url;\n depGraph.addNode(to);\n depGraph.addDependency(from, to);\n }\n }\n\n // Topological sort will throw a DependencyCycleError if cycles exist\n const overallOrder = depGraph.overallOrder();\n const pending = new Set<string>();\n\n for (const id of overallOrder) {\n const ep = entryPoints.get(id);\n if (ep && ep.state !== STATE_DONE) {\n pending.add(id);\n }\n }\n\n if (pending.size === 0) {\n subscriber.next(graph);\n subscriber.complete();\n\n return;\n }\n\n const inDegree = new Map<string, number>();\n const readyQueue: string[] = [];\n\n for (const id of pending) {\n const directDeps = depGraph.directDependenciesOf(id);\n let pendingDepsCount = 0;\n for (const dep of directDeps) {\n if (pending.has(dep)) {\n pendingDepsCount++;\n }\n }\n inDegree.set(id, pendingDepsCount);\n if (pendingDepsCount === 0) {\n readyQueue.push(id);\n }\n }\n\n const maxConcurrency = Math.max(1, Math.min(availableParallelism() - 1, 8));\n let activeCount = 0;\n let buildError: unknown = null;\n let isCancelled = false;\n const activeSubscriptions = new Set<Subscription>();\n\n const toError = (err: unknown): Error => {\n if (err instanceof Error) {\n return err;\n }\n if (typeof err === 'string') {\n return new Error(err);\n }\n if (\n err &&\n typeof err === 'object' &&\n 'message' in err &&\n typeof (err as { message: unknown }).message === 'string'\n ) {\n return new Error((err as { message: string }).message);\n }\n\n return new Error('Build error');\n };\n\n const next = () => {\n if (isCancelled) {\n return;\n }\n\n if (buildError) {\n if (activeCount === 0) {\n subscriber.error(toError(buildError));\n }\n\n return;\n }\n\n if (pending.size === 0 && activeCount === 0) {\n subscriber.next(graph);\n subscriber.complete();\n\n return;\n }\n\n if (activeCount === 0 && readyQueue.length === 0 && pending.size > 0) {\n const pendingIds = [...pending].join(', ');\n subscriber.error(new Error(`Deadlock detected: unresolved dependencies for [${pendingIds}]`));\n\n return;\n }\n\n while (activeCount < maxConcurrency && readyQueue.length > 0) {\n const id = readyQueue.shift();\n if (!id) {\n break;\n }\n\n const ep = entryPoints.get(id);\n if (!ep) {\n buildError = new Error(`Entry point node not found for '${id}'`);\n readyQueue.length = 0;\n if (activeCount === 0) {\n subscriber.error(toError(buildError));\n }\n\n return;\n }\n\n activeCount++;\n\n const scopedGraph = new ScopedBuildGraph(graph, ep);\n const run$ = of(scopedGraph).pipe(\n tap(() => {\n ep.state = STATE_IN_PROGRESS;\n }),\n epTransform,\n catchError(err => {\n ep.state = STATE_ERROR;\n throw err;\n }),\n finalize(() => {\n if (!options.watch) {\n ep.dispose();\n }\n }),\n );\n\n const sub: Subscription = run$.subscribe({\n error: err => {\n activeSubscriptions.delete(sub);\n activeCount--;\n if (!buildError) {\n buildError = err;\n readyQueue.length = 0;\n }\n next();\n },\n complete: () => {\n activeSubscriptions.delete(sub);\n activeCount--;\n pending.delete(id);\n\n for (const depId of depGraph.directDependantsOf(id)) {\n if (pending.has(depId)) {\n const remaining = (inDegree.get(depId) ?? 1) - 1;\n inDegree.set(depId, remaining);\n if (remaining === 0) {\n readyQueue.push(depId);\n }\n }\n }\n\n next();\n },\n });\n\n activeSubscriptions.add(sub);\n }\n };\n\n next();\n\n return () => {\n isCancelled = true;\n readyQueue.length = 0;\n for (const activeSub of activeSubscriptions) {\n activeSub.unsubscribe();\n }\n activeSubscriptions.clear();\n };\n }),\n ),\n );\n\nfunction printBuiltAngularPackage(ngPackage: Node, startTime: number): void {\n log.success('\\n------------------------------------------------------------------------------');\n log.success(`Built Angular Package\n- from: ${ngPackage.data.src}\n- to: ${ngPackage.data.dest}`);\n log.success('------------------------------------------------------------------------------');\n const b = colors.bold;\n const w = colors.white;\n log.msg(w(`\\nBuild at: ${b(new Date().toISOString())} - Time: ${b('' + (Date.now() - startTime))}ms\\n`));\n}\n"]}
1
+ {"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/package.transform.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA4C;AAC5C,qCAA+C;AAC/C,+BAmBc;AACd,8DAAyG;AACzG,sDAAoE;AACpE,wCAAgG;AAEhG,uEAA6E;AAC7E,0CAAwC;AACxC,oCAAoC;AACpC,uDAA+B;AAC/B,2DAAuD;AACvD,mCAAiH;AAGjH;;;;;;;;;;;;;;;GAeG;AACI,MAAM,uBAAuB,GAClC,CACE,OAAe,EACf,OAAyB,EACzB,qBAAgC,EAChC,uBAAkC,EAClC,mBAA8B,EAC9B,EAAE,CACJ,CAAC,OAA+B,EAA0B,EAAE;IAC1D,aAAG,CA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AI,mBAAmB,EAAE,CAAC;YAC5C,SAAS,CAAC,WAAW,EAAE,CAAC;QAC1B,CAAC;QACD,mBAAmB,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC,CAAC,CACL,CACF,CAAC;AAEJ,SAAS,wBAAwB,CAAC,SAAe,EAAE,SAAiB;IAClE,aAAG,CAAC,OAAO,CAAC,kFAAkF,CAAC,CAAC;IAChG,aAAG,CAAC,OAAO,CAAC;UACJ,SAAS,CAAC,IAAI,CAAC,GAAG;UAClB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/B,aAAG,CAAC,OAAO,CAAC,gFAAgF,CAAC,CAAC;IAC9F,MAAM,CAAC,GAAG,cAAM,CAAC,IAAI,CAAC;IACtB,MAAM,CAAC,GAAG,cAAM,CAAC,KAAK,CAAC;IACvB,aAAG,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["import { DepGraph } from 'dependency-graph';\nimport { availableParallelism } from 'node:os';\nimport {\n EMPTY,\n NEVER,\n Observable,\n Subscription,\n catchError,\n concatMap,\n debounceTime,\n filter,\n finalize,\n last,\n map,\n of as observableOf,\n of,\n pipe,\n repeat,\n startWith,\n switchMap,\n tap,\n} from 'rxjs';\nimport { createFileWatch, invalidateEntryPointsAndCacheOnFileChange } from '../file-system/file-watcher';\nimport { BuildGraph, ScopedBuildGraph } from '../graph/build-graph';\nimport { Node, STATE_DONE, STATE_ERROR, STATE_IN_PROGRESS, STATE_PENDING } from '../graph/node';\nimport { Transform } from '../graph/transform';\nimport { shutdownSassWorkerPool } from '../styles/stylesheets/sass-language';\nimport { colors } from '../utils/color';\nimport { rmdir } from '../utils/fs';\nimport log from '../utils/log';\nimport { discoverPackages } from './discover-packages';\nimport { EntryPointNode, PackageNode, findPackageNode, isEntryPoint, isEntryPointPending, ngUrl } from './nodes';\nimport { NgPackagrOptions } from './options.di';\n\n/**\n * A transformation for building an npm package:\n *\n * - discoverPackages\n * - options\n * - initTsConfig\n * - analyzeTsSources (thereby extracting template and stylesheet files)\n * - for each entry point\n * - run the entryPontTransform\n *\n * @param project Project token, reference to `ng-package.json`\n * @param options ng-packagr options\n * @param initTsConfigTransform Transformation initializing the tsconfig of each entry point.\n * @param analyseSourcesTransform Transformation analyzing the typescript source files of each entry point.\n * @param entryPointTransform Transformation for asset rendering and compilation of a single entry point.\n */\nexport const packageTransformFactory =\n (\n project: string,\n options: NgPackagrOptions,\n initTsConfigTransform: Transform,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform,\n ) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n log.info(`Building Angular Package`);\n\n const buildTransform = options.watch\n ? watchTransformFactory(project, options, analyseSourcesTransform, entryPointTransform)\n : buildTransformFactory(project, options, analyseSourcesTransform, entryPointTransform);\n\n const pkgUri = ngUrl(project);\n const ngPkg = new PackageNode(pkgUri);\n\n return source$.pipe(\n // Discover packages and entry points\n // Clean the primary dest folder (should clean all secondary sub-directory, as well)\n switchMap(async graph => {\n ngPkg.data = await discoverPackages({ project });\n\n graph.put(ngPkg);\n const { dest, deleteDestPath } = ngPkg.data;\n\n if (deleteDestPath) {\n try {\n await rmdir(dest, { recursive: true });\n } catch {}\n }\n\n const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {\n const { destinationFiles, moduleId } = entryPoint;\n const node = new EntryPointNode(\n ngUrl(moduleId),\n ngPkg.cache.sourcesFileCache,\n ngPkg.cache.moduleResolutionCache,\n );\n node.data = { entryPoint, destinationFiles };\n node.state = STATE_PENDING;\n ngPkg.dependsOn(node);\n\n return node;\n });\n\n // Add entry points to graph\n return graph.put(entryPoints);\n }),\n // Initialize the tsconfig for each entry point\n initTsConfigTransform,\n // perform build\n buildTransform,\n finalize(() => {\n for (const node of ngPkg.dependents) {\n if (node instanceof EntryPointNode) {\n node.cache?.stylesheetProcessor?.destroy();\n }\n }\n shutdownSassWorkerPool();\n }),\n );\n };\n\nconst watchTransformFactory =\n (project: string, options: NgPackagrOptions, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const CompleteWaitingForFileChange = '\\nCompilation complete. Watching for file changes...';\n const FileChangeDetected = '\\nFile change detected. Starting incremental compilation...';\n const FailedWaitingForFileChange = '\\nCompilation failed. Watching for file changes...';\n\n return source$.pipe(\n switchMap(graph => {\n const {\n data,\n cache: { sourcesFileCache },\n } = findPackageNode(graph);\n const { onFileChange, watcher } = createFileWatch([], [data.dest + '/'], options.poll);\n graph.watcher = watcher;\n\n return onFileChange.pipe(\n map(fileChange => invalidateEntryPointsAndCacheOnFileChange(graph, [fileChange.filePath], sourcesFileCache)),\n filter(isChanged => isChanged),\n debounceTime(100),\n tap(() => log.msg(FileChangeDetected)),\n startWith(undefined),\n map(() => graph),\n );\n }),\n switchMap(graph => {\n const startTime = Date.now();\n const pkgUri = ngUrl(project);\n const ngPkg = graph.get(pkgUri);\n\n return observableOf(graph).pipe(\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform, options),\n repeat({ delay: () => (graph.some(isEntryPointPending()) ? of(1) : EMPTY) }),\n last(),\n tap(() => printBuiltAngularPackage(ngPkg, startTime)),\n catchError(error => {\n log.error(error);\n log.msg(FailedWaitingForFileChange);\n\n return NEVER;\n }),\n tap(() => log.msg(CompleteWaitingForFileChange)),\n );\n }),\n );\n };\n\nconst buildTransformFactory =\n (project: string, options: NgPackagrOptions, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n return source$.pipe(\n switchMap(graph => {\n const startTime = Date.now();\n const pkgUri = ngUrl(project);\n const ngPkg = graph.get(pkgUri);\n\n return observableOf(graph).pipe(\n // Analyse dependencies and external resources for each entry point\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform, options),\n tap(() => printBuiltAngularPackage(ngPkg, startTime)),\n );\n }),\n );\n };\n\nconst scheduleEntryPoints = (epTransform: Transform, options: NgPackagrOptions): Transform =>\n pipe(\n concatMap(\n graph =>\n new Observable<BuildGraph>(subscriber => {\n // Calculate node/dependency depth and determine build order\n const depGraph = new DepGraph({ circular: false });\n const entryPoints = new Map<string, EntryPointNode>();\n\n for (const node of graph.values()) {\n if (!isEntryPoint(node)) {\n continue;\n }\n\n // Remove `ng://` prefix for better error messages\n const from = node.url.startsWith('ng://') ? node.url.slice(5) : node.url;\n entryPoints.set(from, node);\n depGraph.addNode(from);\n\n for (const dep of node.dependents) {\n if (!isEntryPoint(dep)) {\n continue;\n }\n\n const to = dep.url.startsWith('ng://') ? dep.url.slice(5) : dep.url;\n depGraph.addNode(to);\n depGraph.addDependency(from, to);\n }\n }\n\n // Topological sort will throw a DependencyCycleError if cycles exist\n const overallOrder = depGraph.overallOrder();\n const pending = new Set<string>();\n\n for (const id of overallOrder) {\n const ep = entryPoints.get(id);\n if (ep && ep.state !== STATE_DONE) {\n pending.add(id);\n }\n }\n\n if (pending.size === 0) {\n subscriber.next(graph);\n subscriber.complete();\n\n return;\n }\n\n const inDegree = new Map<string, number>();\n const readyQueue: string[] = [];\n\n for (const id of pending) {\n const directDeps = depGraph.directDependenciesOf(id);\n let pendingDepsCount = 0;\n for (const dep of directDeps) {\n if (pending.has(dep)) {\n pendingDepsCount++;\n }\n }\n inDegree.set(id, pendingDepsCount);\n if (pendingDepsCount === 0) {\n readyQueue.push(id);\n }\n }\n\n const maxConcurrency = Math.max(1, Math.min(availableParallelism() - 1, 8));\n const isParallel = maxConcurrency > 1 && pending.size > 1;\n let activeCount = 0;\n let buildError: unknown = null;\n let isCancelled = false;\n const activeSubscriptions = new Set<Subscription>();\n\n const toError = (err: unknown): Error => {\n if (err instanceof Error) {\n return err;\n }\n if (typeof err === 'string') {\n return new Error(err);\n }\n if (\n err &&\n typeof err === 'object' &&\n 'message' in err &&\n typeof (err as { message: unknown }).message === 'string'\n ) {\n return new Error((err as { message: string }).message);\n }\n\n return new Error('Build error');\n };\n\n const next = () => {\n if (isCancelled) {\n return;\n }\n\n if (buildError) {\n if (activeCount === 0) {\n subscriber.error(toError(buildError));\n }\n\n return;\n }\n\n if (pending.size === 0 && activeCount === 0) {\n subscriber.next(graph);\n subscriber.complete();\n\n return;\n }\n\n if (activeCount === 0 && readyQueue.length === 0 && pending.size > 0) {\n const pendingIds = [...pending].join(', ');\n subscriber.error(new Error(`Deadlock detected: unresolved dependencies for [${pendingIds}]`));\n\n return;\n }\n\n while (activeCount < maxConcurrency && readyQueue.length > 0) {\n const id = readyQueue.shift();\n if (!id) {\n break;\n }\n\n const ep = entryPoints.get(id);\n if (!ep) {\n buildError = new Error(`Entry point node not found for '${id}'`);\n readyQueue.length = 0;\n if (activeCount === 0) {\n subscriber.error(toError(buildError));\n }\n\n return;\n }\n\n activeCount++;\n\n const scopedGraph = new ScopedBuildGraph(graph, ep, isParallel);\n const run$ = of(scopedGraph).pipe(\n tap(() => {\n ep.state = STATE_IN_PROGRESS;\n }),\n epTransform,\n catchError(err => {\n ep.state = STATE_ERROR;\n throw err;\n }),\n finalize(() => {\n if (!options.watch) {\n ep.dispose();\n }\n }),\n );\n\n const sub: Subscription = run$.subscribe({\n error: err => {\n activeSubscriptions.delete(sub);\n activeCount--;\n if (!buildError) {\n buildError = err;\n readyQueue.length = 0;\n }\n next();\n },\n complete: () => {\n activeSubscriptions.delete(sub);\n activeCount--;\n pending.delete(id);\n\n for (const depId of depGraph.directDependantsOf(id)) {\n if (pending.has(depId)) {\n const remaining = (inDegree.get(depId) ?? 1) - 1;\n inDegree.set(depId, remaining);\n if (remaining === 0) {\n readyQueue.push(depId);\n }\n }\n }\n\n next();\n },\n });\n\n activeSubscriptions.add(sub);\n }\n };\n\n next();\n\n return () => {\n isCancelled = true;\n readyQueue.length = 0;\n for (const activeSub of activeSubscriptions) {\n activeSub.unsubscribe();\n }\n activeSubscriptions.clear();\n };\n }),\n ),\n );\n\nfunction printBuiltAngularPackage(ngPackage: Node, startTime: number): void {\n log.success('\\n------------------------------------------------------------------------------');\n log.success(`Built Angular Package\n- from: ${ngPackage.data.src}\n- to: ${ngPackage.data.dest}`);\n log.success('------------------------------------------------------------------------------');\n const b = colors.bold;\n const w = colors.white;\n log.msg(w(`\\nBuild at: ${b(new Date().toISOString())} - Time: ${b('' + (Date.now() - startTime))}ms\\n`));\n}\n"]}
@@ -130,6 +130,12 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, option
130
130
  const errorDiagnostics = [];
131
131
  for (const diagnostic of allDiagnostics) {
132
132
  if (diagnostic.category === typescript_1.default.DiagnosticCategory.Error) {
133
+ if (diagnostic.code === 6059) {
134
+ const message = typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, '');
135
+ if (message.includes('.ngtypecheck.ts')) {
136
+ continue;
137
+ }
138
+ }
133
139
  errorDiagnostics.push(diagnostic);
134
140
  }
135
141
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;AAkBA,gDAiNC;AAnOD,wDAA8G;AAC9G,yCAAiC;AACjC,4DAA4B;AAE5B,+CAA2E;AAG3E,mEAA4F;AAC5F,uDAA+B;AAM/B,SAAS,gBAAgB,CAAC,OAA0B;IAClD,OAAO,eAAe,IAAI,OAAO,IAAI,OAAQ,OAA2C,CAAC,aAAa,KAAK,UAAU,CAAC;AACxH,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAA6B,EAC7B,qBAA+C,EAC/C,OAAyB,EACzB,YAAuC,EACvC,mBAAyC;IAE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C,UAAU,CAAC,EAAE,CAAC;YAClE,SAAS;QACX,CAAC;QAED,IAAI,eAAe,CAAC,sBAAsB,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;YACtE,SAAS;QACX,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;AACH,CAAC","sourcesContent":["import { CompilerOptions, NgtscProgram, ParsedConfiguration, formatDiagnostics } from '@angular/compiler-cli';\nimport { join } from 'node:path';\nimport ts from 'typescript';\nimport { BuildGraph } from '../graph/build-graph';\nimport { findPackageNode, getActiveEntryPoint } from '../ng-package/nodes';\nimport { NgPackagrOptions } from '../ng-package/options.di';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from '../ts/cache-compiler-host';\nimport log from '../utils/log';\n\ninterface BuilderWithBuildInfo {\n emitBuildInfo(writeFile?: ts.WriteFileCallback, cancellationToken?: ts.CancellationToken): ts.EmitResult;\n}\n\nfunction hasEmitBuildInfo(builder: ts.BuilderProgram): builder is ts.BuilderProgram & BuilderWithBuildInfo {\n return 'emitBuildInfo' in builder && typeof (builder as unknown as BuilderWithBuildInfo).emitBuildInfo === 'function';\n}\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n options: NgPackagrOptions,\n extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n) {\n const { cacheDirectory, watch, cacheEnabled } = options;\n const tsConfigOptions: CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint = getActiveEntryPoint(graph);\n const ngPackageNode = findPackageNode(graph);\n const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;\n\n const cacheDir = cacheEnabled && cacheDirectory;\n if (cacheDir) {\n tsConfigOptions.incremental ??= true;\n tsConfigOptions.tsBuildInfoFile ??= join(\n cacheDir,\n `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`,\n );\n }\n\n const tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n inlineStyleLanguage,\n );\n\n const cache = entryPoint.cache;\n let usingBuildInfo = false;\n\n let oldBuilder = cache.oldBuilder;\n if (!oldBuilder && cacheDir) {\n oldBuilder = ts.readBuilderProgram(tsConfigOptions, tsCompilerHost);\n usingBuildInfo = true;\n }\n\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);\n\n const angularCompiler = angularProgram.compiler;\n const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;\n\n // SourceFile versions are required for builder programs.\n // The wrapped host inside NgtscProgram adds additional files that will not have versions.\n const typeScriptProgram = angularProgram.getTsProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n let builder: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n if (watch || cacheDir) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n oldBuilder,\n );\n cache.oldNgtscProgram = angularProgram;\n } else {\n builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(typeScriptProgram, tsCompilerHost);\n }\n\n // Update semantic diagnostics cache\n const affectedFiles = new Set<ts.SourceFile>();\n\n // Analyze affected files when in watch mode for incremental type checking\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (true) {\n const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, sourceFile => {\n // If the affected file is a TTC shim, add the shim's original source file.\n // This ensures that changes that affect TTC are typechecked even when the changes\n // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.\n // For example, changing @Input property types of a directive used in another component's\n // template.\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n\n return true;\n }\n\n return false;\n });\n\n if (!result) {\n break;\n }\n\n affectedFiles.add(result.affected as ts.SourceFile);\n }\n\n // Add all files with associated template type checking files.\n // Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.\n // To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build\n // info is present.\n if (usingBuildInfo) {\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n }\n }\n }\n }\n\n // Collect program level diagnostics\n const allDiagnostics: ts.Diagnostic[] = [\n ...angularCompiler.getOptionDiagnostics(),\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ];\n\n // Required to support asynchronous resource loading\n // Must be done before creating transformers or getting template diagnostics\n await angularCompiler.analyzeAsync();\n\n // Collect source file specific diagnostics\n const { angularDiagnosticCache, declarationDiagnosticCache } = cache;\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (sourceFile.isDeclarationFile || ignoreForDiagnostics.has(sourceFile)) {\n continue;\n }\n\n allDiagnostics.push(...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile));\n\n // Only request declaration diagnostics for affected or uncached files\n if (affectedFiles.has(sourceFile) || !declarationDiagnosticCache.has(sourceFile)) {\n // We use the `typeScriptProgram` instead of `builder` here as a\n // performance workaround for: https://github.com/microsoft/TypeScript/issues/60970\n const declarationDiagnostics = typeScriptProgram.getDeclarationDiagnostics(sourceFile);\n declarationDiagnosticCache.update(sourceFile, declarationDiagnostics);\n }\n\n allDiagnostics.push(...declarationDiagnosticCache.get(sourceFile));\n\n // Only request Angular template diagnostics for affected files to avoid\n // overhead of template diagnostics for unchanged files.\n if (affectedFiles.has(sourceFile) || !angularDiagnosticCache.has(sourceFile)) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(\n sourceFile,\n affectedFiles.size === 1 ? /** OptimizeFor.SingleFile **/ 0 : /** OptimizeFor.WholeProgram */ 1,\n );\n\n angularDiagnosticCache.update(sourceFile, angularDiagnostics);\n }\n\n allDiagnostics.push(...angularDiagnosticCache.get(sourceFile));\n }\n\n const otherDiagnostics = [];\n const errorDiagnostics = [];\n for (const diagnostic of allDiagnostics) {\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n errorDiagnostics.push(diagnostic);\n } else {\n otherDiagnostics.push(diagnostic);\n }\n }\n\n if (otherDiagnostics.length) {\n log.msg(formatDiagnostics(otherDiagnostics));\n }\n\n if (errorDiagnostics.length) {\n throw new Error(formatDiagnostics(errorDiagnostics));\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n\n const writeFile: ts.WriteFileCallback = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {\n if (sourceFiles) {\n for (const sourceFile of sourceFiles) {\n if (!sourceFile.isDeclarationFile) {\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n }\n }\n }\n\n tsCompilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n };\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (sourceFile.isDeclarationFile || ignoreForEmit.has(sourceFile)) {\n continue;\n }\n\n if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {\n continue;\n }\n\n builder.emit(sourceFile, writeFile, undefined, undefined, transformers);\n }\n\n if (hasEmitBuildInfo(builder)) {\n builder.emitBuildInfo(writeFile);\n }\n}\n"]}
1
+ {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;AAkBA,gDAwNC;AA1OD,wDAA8G;AAC9G,yCAAiC;AACjC,4DAA4B;AAE5B,+CAA2E;AAG3E,mEAA4F;AAC5F,uDAA+B;AAM/B,SAAS,gBAAgB,CAAC,OAA0B;IAClD,OAAO,eAAe,IAAI,OAAO,IAAI,OAAQ,OAA2C,CAAC,aAAa,KAAK,UAAU,CAAC;AACxH,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAA6B,EAC7B,qBAA+C,EAC/C,OAAyB,EACzB,YAAuC,EACvC,mBAAyC;IAEzC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,eAAe,GAAoB,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;IAClF,MAAM,UAAU,GAAG,IAAA,2BAAmB,EAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC;IAEnE,MAAM,QAAQ,GAAG,YAAY,IAAI,cAAc,CAAC;IAChD,IAAI,QAAQ,EAAE,CAAC;QACb,eAAe,CAAC,WAAW,KAAK,IAAI,CAAC;QACrC,eAAe,CAAC,eAAe,KAAK,IAAA,gBAAI,EACtC,QAAQ,EACR,eAAe,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,cAAc,CACvE,CAAC;IACJ,CAAC;IAED,MAAM,cAAc,GAAG,IAAA,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CompilerOptions, NgtscProgram, ParsedConfiguration, formatDiagnostics } from '@angular/compiler-cli';\nimport { join } from 'node:path';\nimport ts from 'typescript';\nimport { BuildGraph } from '../graph/build-graph';\nimport { findPackageNode, getActiveEntryPoint } from '../ng-package/nodes';\nimport { NgPackagrOptions } from '../ng-package/options.di';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from '../ts/cache-compiler-host';\nimport log from '../utils/log';\n\ninterface BuilderWithBuildInfo {\n emitBuildInfo(writeFile?: ts.WriteFileCallback, cancellationToken?: ts.CancellationToken): ts.EmitResult;\n}\n\nfunction hasEmitBuildInfo(builder: ts.BuilderProgram): builder is ts.BuilderProgram & BuilderWithBuildInfo {\n return 'emitBuildInfo' in builder && typeof (builder as unknown as BuilderWithBuildInfo).emitBuildInfo === 'function';\n}\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n options: NgPackagrOptions,\n extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n) {\n const { cacheDirectory, watch, cacheEnabled } = options;\n const tsConfigOptions: CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint = getActiveEntryPoint(graph);\n const ngPackageNode = findPackageNode(graph);\n const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;\n\n const cacheDir = cacheEnabled && cacheDirectory;\n if (cacheDir) {\n tsConfigOptions.incremental ??= true;\n tsConfigOptions.tsBuildInfoFile ??= join(\n cacheDir,\n `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`,\n );\n }\n\n const tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n inlineStyleLanguage,\n );\n\n const cache = entryPoint.cache;\n let usingBuildInfo = false;\n\n let oldBuilder = cache.oldBuilder;\n if (!oldBuilder && cacheDir) {\n oldBuilder = ts.readBuilderProgram(tsConfigOptions, tsCompilerHost);\n usingBuildInfo = true;\n }\n\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);\n\n const angularCompiler = angularProgram.compiler;\n const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;\n\n // SourceFile versions are required for builder programs.\n // The wrapped host inside NgtscProgram adds additional files that will not have versions.\n const typeScriptProgram = angularProgram.getTsProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n let builder: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n if (watch || cacheDir) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n oldBuilder,\n );\n cache.oldNgtscProgram = angularProgram;\n } else {\n builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(typeScriptProgram, tsCompilerHost);\n }\n\n // Update semantic diagnostics cache\n const affectedFiles = new Set<ts.SourceFile>();\n\n // Analyze affected files when in watch mode for incremental type checking\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (true) {\n const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, sourceFile => {\n // If the affected file is a TTC shim, add the shim's original source file.\n // This ensures that changes that affect TTC are typechecked even when the changes\n // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.\n // For example, changing @Input property types of a directive used in another component's\n // template.\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n\n return true;\n }\n\n return false;\n });\n\n if (!result) {\n break;\n }\n\n affectedFiles.add(result.affected as ts.SourceFile);\n }\n\n // Add all files with associated template type checking files.\n // Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.\n // To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build\n // info is present.\n if (usingBuildInfo) {\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n }\n }\n }\n }\n\n // Collect program level diagnostics\n const allDiagnostics: ts.Diagnostic[] = [\n ...angularCompiler.getOptionDiagnostics(),\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ];\n\n // Required to support asynchronous resource loading\n // Must be done before creating transformers or getting template diagnostics\n await angularCompiler.analyzeAsync();\n\n // Collect source file specific diagnostics\n const { angularDiagnosticCache, declarationDiagnosticCache } = cache;\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (sourceFile.isDeclarationFile || ignoreForDiagnostics.has(sourceFile)) {\n continue;\n }\n\n allDiagnostics.push(...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile));\n\n // Only request declaration diagnostics for affected or uncached files\n if (affectedFiles.has(sourceFile) || !declarationDiagnosticCache.has(sourceFile)) {\n // We use the `typeScriptProgram` instead of `builder` here as a\n // performance workaround for: https://github.com/microsoft/TypeScript/issues/60970\n const declarationDiagnostics = typeScriptProgram.getDeclarationDiagnostics(sourceFile);\n declarationDiagnosticCache.update(sourceFile, declarationDiagnostics);\n }\n\n allDiagnostics.push(...declarationDiagnosticCache.get(sourceFile));\n\n // Only request Angular template diagnostics for affected files to avoid\n // overhead of template diagnostics for unchanged files.\n if (affectedFiles.has(sourceFile) || !angularDiagnosticCache.has(sourceFile)) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(\n sourceFile,\n affectedFiles.size === 1 ? /** OptimizeFor.SingleFile **/ 0 : /** OptimizeFor.WholeProgram */ 1,\n );\n\n angularDiagnosticCache.update(sourceFile, angularDiagnostics);\n }\n\n allDiagnostics.push(...angularDiagnosticCache.get(sourceFile));\n }\n\n const otherDiagnostics = [];\n const errorDiagnostics = [];\n for (const diagnostic of allDiagnostics) {\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n if (diagnostic.code === 6059) {\n const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '');\n if (message.includes('.ngtypecheck.ts')) {\n continue;\n }\n }\n\n errorDiagnostics.push(diagnostic);\n } else {\n otherDiagnostics.push(diagnostic);\n }\n }\n\n if (otherDiagnostics.length) {\n log.msg(formatDiagnostics(otherDiagnostics));\n }\n\n if (errorDiagnostics.length) {\n throw new Error(formatDiagnostics(errorDiagnostics));\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n\n const writeFile: ts.WriteFileCallback = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {\n if (sourceFiles) {\n for (const sourceFile of sourceFiles) {\n if (!sourceFile.isDeclarationFile) {\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n }\n }\n }\n\n tsCompilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n };\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (sourceFile.isDeclarationFile || ignoreForEmit.has(sourceFile)) {\n continue;\n }\n\n if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {\n continue;\n }\n\n builder.emit(sourceFile, writeFile, undefined, undefined, transformers);\n }\n\n if (hasEmitBuildInfo(builder)) {\n builder.emitBuildInfo(writeFile);\n }\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import { type Options, type Ora } from 'ora';
2
+ import type { BuildGraph } from '../graph/build-graph';
3
+ /**
4
+ * Resets the active spinner count. Intended for testing.
5
+ */
6
+ export declare function resetActiveSpinners(): void;
7
+ /**
8
+ * Returns the current count of active spinners. Intended for testing.
9
+ */
10
+ export declare function getActiveSpinnersCount(): number;
11
+ /**
12
+ * Creates and returns an Ora spinner configured for ng-packagr.
13
+ *
14
+ * When building in parallel or if another spinner is already spinning,
15
+ * the spinner is disabled (`isEnabled: false`) to avoid concurrent spinner
16
+ * corruption and terminal flooding.
17
+ */
18
+ export declare function openSpinner(textOrOptions?: string | Options, graphOrIsParallel?: boolean | BuildGraph): Ora;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resetActiveSpinners = resetActiveSpinners;
7
+ exports.getActiveSpinnersCount = getActiveSpinnersCount;
8
+ exports.openSpinner = openSpinner;
9
+ const ora_1 = __importDefault(require("ora"));
10
+ let activeSpinners = 0;
11
+ /**
12
+ * Resets the active spinner count. Intended for testing.
13
+ */
14
+ function resetActiveSpinners() {
15
+ activeSpinners = 0;
16
+ }
17
+ /**
18
+ * Returns the current count of active spinners. Intended for testing.
19
+ */
20
+ function getActiveSpinnersCount() {
21
+ return activeSpinners;
22
+ }
23
+ /**
24
+ * Creates and returns an Ora spinner configured for ng-packagr.
25
+ *
26
+ * When building in parallel or if another spinner is already spinning,
27
+ * the spinner is disabled (`isEnabled: false`) to avoid concurrent spinner
28
+ * corruption and terminal flooding.
29
+ */
30
+ function openSpinner(textOrOptions, graphOrIsParallel) {
31
+ const isParallel = typeof graphOrIsParallel === 'boolean' ? graphOrIsParallel : (graphOrIsParallel?.isParallel ?? false);
32
+ const baseOptions = typeof textOrOptions === 'string' ? { text: textOrOptions } : { ...textOrOptions };
33
+ const options = {
34
+ hideCursor: false,
35
+ discardStdin: false,
36
+ ...baseOptions,
37
+ ...(isParallel ? { isEnabled: false } : {}),
38
+ };
39
+ const spinner = (0, ora_1.default)(options);
40
+ const origStart = spinner.start.bind(spinner);
41
+ const origStop = spinner.stop.bind(spinner);
42
+ let isCounted = false;
43
+ spinner.start = (text) => {
44
+ if (activeSpinners > 0 && !isCounted) {
45
+ spinner.isEnabled = false;
46
+ }
47
+ else if (spinner.isEnabled && !isCounted) {
48
+ activeSpinners++;
49
+ isCounted = true;
50
+ }
51
+ return origStart(text);
52
+ };
53
+ spinner.stop = () => {
54
+ if (isCounted) {
55
+ activeSpinners--;
56
+ isCounted = false;
57
+ }
58
+ return origStop();
59
+ };
60
+ return spinner;
61
+ }
62
+ //# sourceMappingURL=spinner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../../../src/lib/utils/spinner.ts"],"names":[],"mappings":";;;;;AAQA,kDAEC;AAKD,wDAEC;AASD,kCAuCC;AAjED,8CAAkD;AAGlD,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB;;GAEG;AACH,SAAgB,mBAAmB;IACjC,cAAc,GAAG,CAAC,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB;IACpC,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,aAAgC,EAAE,iBAAwC;IACpG,MAAM,UAAU,GACd,OAAO,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,UAAU,IAAI,KAAK,CAAC,CAAC;IAExG,MAAM,WAAW,GAAY,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,CAAC;IAEhH,MAAM,OAAO,GAAY;QACvB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;QACnB,GAAG,WAAW;QACd,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,OAAO,CAAC,CAAC;IAC7B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,OAAO,CAAC,KAAK,GAAG,CAAC,IAAa,EAAE,EAAE;QAChC,IAAI,cAAc,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACrC,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;QAC5B,CAAC;aAAM,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,SAAS,EAAE,CAAC;YAC3C,cAAc,EAAE,CAAC;YACjB,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC;QAED,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE;QAClB,IAAI,SAAS,EAAE,CAAC;YACd,cAAc,EAAE,CAAC;YACjB,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC;QAED,OAAO,QAAQ,EAAE,CAAC;IACpB,CAAC,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import ora, { type Options, type Ora } from 'ora';\nimport type { BuildGraph } from '../graph/build-graph';\n\nlet activeSpinners = 0;\n\n/**\n * Resets the active spinner count. Intended for testing.\n */\nexport function resetActiveSpinners(): void {\n activeSpinners = 0;\n}\n\n/**\n * Returns the current count of active spinners. Intended for testing.\n */\nexport function getActiveSpinnersCount(): number {\n return activeSpinners;\n}\n\n/**\n * Creates and returns an Ora spinner configured for ng-packagr.\n *\n * When building in parallel or if another spinner is already spinning,\n * the spinner is disabled (`isEnabled: false`) to avoid concurrent spinner\n * corruption and terminal flooding.\n */\nexport function openSpinner(textOrOptions?: string | Options, graphOrIsParallel?: boolean | BuildGraph): Ora {\n const isParallel =\n typeof graphOrIsParallel === 'boolean' ? graphOrIsParallel : (graphOrIsParallel?.isParallel ?? false);\n\n const baseOptions: Options = typeof textOrOptions === 'string' ? { text: textOrOptions } : { ...textOrOptions };\n\n const options: Options = {\n hideCursor: false,\n discardStdin: false,\n ...baseOptions,\n ...(isParallel ? { isEnabled: false } : {}),\n };\n\n const spinner = ora(options);\n const origStart = spinner.start.bind(spinner);\n const origStop = spinner.stop.bind(spinner);\n let isCounted = false;\n\n spinner.start = (text?: string) => {\n if (activeSpinners > 0 && !isCounted) {\n spinner.isEnabled = false;\n } else if (spinner.isEnabled && !isCounted) {\n activeSpinners++;\n isCounted = true;\n }\n\n return origStart(text);\n };\n\n spinner.stop = () => {\n if (isCounted) {\n activeSpinners--;\n isCounted = false;\n }\n\n return origStop();\n };\n\n return spinner;\n}\n"]}