ng-packagr 22.3.0-next.1 → 22.3.0-next.2

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.3.0-next.1",
3
+ "version": "22.3.0-next.2",
4
4
  "description": "Compile and package Angular libraries in Angular Package Format (APF)",
5
5
  "keywords": [
6
6
  "apf",
@@ -18,11 +18,8 @@ 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 store: Map<string, Node>;
22
- private _watcher?;
23
- constructor(store?: Map<string, Node>);
24
- get watcher(): FSWatcher | undefined;
25
- set watcher(watcher: FSWatcher | undefined);
21
+ private store;
22
+ watcher?: FSWatcher;
26
23
  put(value: Node | Node[]): this;
27
24
  private insert;
28
25
  get(url: string): Node;
@@ -34,11 +31,3 @@ export declare class BuildGraph implements Traversable<Node> {
34
31
  find<T extends Node = Node>(by: ComplexPredicate<Node, T>): T | undefined;
35
32
  get size(): number;
36
33
  }
37
- export declare class ScopedBuildGraph<T extends Node = Node> extends BuildGraph {
38
- readonly parentGraph: BuildGraph;
39
- readonly activeEntryPoint: T;
40
- constructor(parentGraph: BuildGraph, activeEntryPoint: T);
41
- get watcher(): FSWatcher | undefined;
42
- set watcher(watcher: FSWatcher | undefined);
43
- }
44
- export declare function isScopedBuildGraph<T extends Node = Node>(graph: BuildGraph): graph is ScopedBuildGraph<T>;
@@ -1,24 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScopedBuildGraph = exports.BuildGraph = void 0;
4
- exports.isScopedBuildGraph = isScopedBuildGraph;
3
+ exports.BuildGraph = void 0;
5
4
  const nodes_1 = require("../ng-package/nodes");
6
5
  /**
7
6
  * A tree of source files. Eventually, it's a graph. Ideally, it's an acyclic directed graph.
8
7
  * Technically, it's implemented as a map-like collection with references between map entries.
9
8
  */
10
9
  class BuildGraph {
11
- store;
12
- _watcher;
13
- constructor(store) {
14
- this.store = store ?? new Map();
15
- }
16
- get watcher() {
17
- return this._watcher;
18
- }
19
- set watcher(watcher) {
20
- this._watcher = watcher;
21
- }
10
+ store = new Map();
11
+ watcher;
22
12
  put(value) {
23
13
  if (value instanceof Array) {
24
14
  for (const node of value) {
@@ -86,23 +76,4 @@ class BuildGraph {
86
76
  }
87
77
  }
88
78
  exports.BuildGraph = BuildGraph;
89
- class ScopedBuildGraph extends BuildGraph {
90
- parentGraph;
91
- activeEntryPoint;
92
- constructor(parentGraph, activeEntryPoint) {
93
- super(parentGraph.store);
94
- this.parentGraph = parentGraph;
95
- this.activeEntryPoint = activeEntryPoint;
96
- }
97
- get watcher() {
98
- return this.parentGraph.watcher;
99
- }
100
- set watcher(watcher) {
101
- this.parentGraph.watcher = watcher;
102
- }
103
- }
104
- exports.ScopedBuildGraph = ScopedBuildGraph;
105
- function isScopedBuildGraph(graph) {
106
- return graph instanceof ScopedBuildGraph;
107
- }
108
79
  //# sourceMappingURL=build-graph.js.map
@@ -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,KA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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 ScopedBuildGraph;\n}\n"]}
1
+ {"version":3,"file":"build-graph.js","sourceRoot":"","sources":["../../../../src/lib/graph/build-graph.ts"],"names":[],"mappings":";;;AACA,+CAAkD;AAqBlD;;;GAGG;AACH,MAAa,UAAU;IACb,KAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IACxC,OAAO,CAAa;IAEb,GAAG,CAAC,KAAoB;QAC7B,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,G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Q,EAAE,CAAC;QAEvB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC,IAAS,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,IAAI,CAAwB,EAA6B;QAC9D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;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;AApFD,gCAoFC","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 private store = new Map<string, Node>();\n watcher?: FSWatcher;\n\n public 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 public get(url: string): Node {\n return this.store.get(url);\n }\n\n public has(url: string): boolean {\n return this.store.has(url);\n }\n\n public entries(): Node[] {\n return Array.from(this.store.values());\n }\n\n public values(): IterableIterator<Node> {\n return this.store.values();\n }\n\n public 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 public 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 public 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"]}
@@ -7,6 +7,7 @@ exports.compileNgcTransformFactory = void 0;
7
7
  const node_path_1 = require("node:path");
8
8
  const ora_1 = __importDefault(require("ora"));
9
9
  const typescript_1 = __importDefault(require("typescript"));
10
+ const select_1 = require("../../graph/select");
10
11
  const transform_1 = require("../../graph/transform");
11
12
  const compile_source_files_1 = require("../../ngc/compile-source-files");
12
13
  const tsconfig_1 = require("../../ts/tsconfig");
@@ -17,15 +18,26 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
17
18
  hideCursor: false,
18
19
  discardStdin: false,
19
20
  });
20
- const entryPoints = graph.filter(nodes_1.isEntryPoint);
21
- const ngPackageNode = (0, nodes_1.findPackageNode)(graph);
22
- const entryPoint = (0, nodes_1.getActiveEntryPoint)(graph);
21
+ const entryPoints = [];
22
+ let entryPoint;
23
+ let ngPackageNode;
24
+ for (const node of graph.values()) {
25
+ if ((0, nodes_1.isEntryPoint)(node)) {
26
+ entryPoints.push(node);
27
+ if ((0, select_1.isInProgress)(node)) {
28
+ entryPoint = node;
29
+ }
30
+ }
31
+ else if ((0, nodes_1.isPackage)(node)) {
32
+ ngPackageNode = node;
33
+ }
34
+ }
23
35
  const projectBasePath = ngPackageNode.data.primary.basePath;
24
36
  try {
25
37
  // Add paths mappings for dependencies
26
38
  const tsConfig = (0, tsconfig_1.setDependenciesTsConfigPaths)(entryPoint.data.tsConfig, entryPoints);
27
39
  // Compile TypeScript sources
28
- const { esm2022, declarations } = entryPoint.data.destinationFiles;
40
+ const { esm2022: esm2022, declarations } = entryPoint.data.destinationFiles;
29
41
  const { basePath, cssUrl, styleIncludePaths, sass } = entryPoint.data.entryPoint;
30
42
  const { moduleResolutionCache } = entryPoint.cache;
31
43
  spinner.start(`Compiling with Angular sources in ${tsConfig.options.compilationMode || 'full'} compilation mode.`);
@@ -41,6 +53,11 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
41
53
  spinner.fail();
42
54
  throw error;
43
55
  }
56
+ finally {
57
+ if (!options.watch) {
58
+ entryPoint.cache.stylesheetProcessor?.destroy();
59
+ }
60
+ }
44
61
  spinner.succeed();
45
62
  return graph;
46
63
  });
@@ -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,EAA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AAE,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;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,8CAAsB;AACtB,4DAA4B;AAC5B,+CAAkD;AAClD,qDAAwE;AACxE,yEAAoE;AAEpE,gDAAiE;AACjE,oCAAgF;AAGzE,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;QAEH,MAAM,WAAW,GAAqB,EAAE,CAAC;QACzC,IAAI,UAA0B,CAAC;QAC/B,IAAI,aAA0B,CAAC;QAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YAClC,IAAI,IAAA,oBAAY,EAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAEvB,IAAI,IAAA,qBAAY,EAAC,IAAI,CAAC,EAAE,CAAC;oBACvB,UAAU,GAAG,IAAI,CAAC;gBACpB,CAAC;YACH,CAAC;iBAAM,IAAI,IAAA,iBAAS,EAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,aAAa,GAAG,IAAI,CAAC;YACvB,CAAC;QACH,CAAC;QAED,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C;YACT,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;gBACnB,UAAU,CAAC,KAAK,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAC;YAClD,CAAC;QACH,CAAC;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA7EW,QAAA,0BAA0B,8BA6ErC","sourcesContent":["import { dirname } from 'node:path';\nimport ora from 'ora';\nimport ts from 'typescript';\nimport { isInProgress } from '../../graph/select';\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 { EntryPointNode, PackageNode, isEntryPoint, isPackage } 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: EntryPointNode[] = [];\n let entryPoint: EntryPointNode;\n let ngPackageNode: PackageNode;\n\n for (const node of graph.values()) {\n if (isEntryPoint(node)) {\n entryPoints.push(node);\n\n if (isInProgress(node)) {\n entryPoint = node;\n }\n } else if (isPackage(node)) {\n ngPackageNode = node;\n }\n }\n\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: 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 } finally {\n if (!options.watch) {\n entryPoint.cache.stylesheetProcessor?.destroy();\n }\n }\n\n spinner.succeed();\n\n return graph;\n });\n};\n"]}
@@ -35,7 +35,7 @@ const nodes_1 = require("../nodes");
35
35
  */
36
36
  const entryPointTransformFactory = (compileTs, writeBundles, writePackage) => (0, rxjs_1.pipe)((0, rxjs_1.tap)(graph => {
37
37
  // Peek the first entry point from the graph
38
- const entryPoint = (0, nodes_1.getActiveEntryPoint)(graph);
38
+ const entryPoint = (0, nodes_1.findEntryPointInProgress)(graph);
39
39
  log_1.default.msg('\n------------------------------------------------------------------------------');
40
40
  log_1.default.msg(`Building entry point '${entryPoint.data.entryPoint.moduleId}'`);
41
41
  log_1.default.msg('------------------------------------------------------------------------------');
@@ -44,7 +44,7 @@ const entryPointTransformFactory = (compileTs, writeBundles, writePackage) => (0
44
44
  compileTs,
45
45
  // After TypeScript: bundling and write package
46
46
  writeBundles, writePackage, (0, rxjs_1.tap)(graph => {
47
- const entryPoint = (0, nodes_1.getActiveEntryPoint)(graph);
47
+ const entryPoint = (0, nodes_1.findEntryPointInProgress)(graph);
48
48
  entryPoint.state = node_1.STATE_DONE;
49
49
  }));
50
50
  exports.entryPointTransformFactory = entryPointTransformFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"entry-point.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/entry-point.transform.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAiC;AACjC,2CAA8C;AAE9C,0DAAkC;AAClC,oCAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,0BAA0B,GAAG,CACxC,SAAoB,EACpB,YAAuB,EACvB,YAAuB,EACZ,EAAE,CACb,IAAA,WAAI,EACF,IAAA,UAAG,EAAC,KAAK,CAAC,EAAE;IACV,4CAA4C;IAC5C,MAAM,UAAU,GAAG,IAAA,2BAAmB,EAAC,KAAK,CAAC,CAAC;IAC9C,aAAG,CAAC,GAAG,CAAC,kFAAkF,CAAC,CAAC;IAC5F,aAAG,CAAC,GAAG,CAAC,yBAAyB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,CAAC;IACzE,aAAG,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAC;AAC5F,CAAC,CAAC;AACF,iCAAiC;AACjC,SAAS;AACT,+CAA+C;AAC/C,YAAY,EACZ,YAAY,EACZ,IAAA,UAAG,EAAC,KAAK,CAAC,EAAE;IACV,MAAM,UAAU,GAAG,IAAA,2BAAmB,EAAC,KAAK,CAAC,CAAC;IAC9C,UAAU,CAAC,KAAK,GAAG,iBAAU,CAAC;AAChC,CAAC,CAAC,CACH,CAAC;AAtBS,QAAA,0BAA0B,8BAsBnC","sourcesContent":["import { pipe, tap } from 'rxjs';\nimport { STATE_DONE } from '../../graph/node';\nimport { Transform } from '../../graph/transform';\nimport log from '../../utils/log';\nimport { getActiveEntryPoint } from '../nodes';\n\n/**\n * A re-write of the `transformSources()` script that transforms an entry point from sources to distributable format.\n *\n * Sources are TypeScript source files accompanied by HTML templates and xCSS stylesheets.\n * See the Angular Package Format for a detailed description of what the distributables include.\n *\n * The current transformation pipeline can be thought of as:\n *\n * - clean\n * - compileTs\n * - downlevelTs\n * - writeBundles\n * - bundleToFesm15\n * - relocateSourceMaps\n * - writePackage\n * - copyStagedFiles (bundles, esm, dts, sourcemaps)\n * - writePackageJson\n *\n * The transformation pipeline is pluggable through the dependency injection system.\n * Sub-transformations are passed to this factory function as arguments.\n *\n * @param compileTs Transformation compiling typescript sources to ES2022 modules.\n * @param writeBundles Transformation flattening ES2022 modules to ESM2022, UMD, and minified UMD.\n * @param writePackage Transformation writing a distribution-ready `package.json` (for publishing to npm registry).\n */\nexport const entryPointTransformFactory = (\n compileTs: Transform,\n writeBundles: Transform,\n writePackage: Transform,\n): Transform =>\n pipe(\n tap(graph => {\n // Peek the first entry point from the graph\n const entryPoint = getActiveEntryPoint(graph);\n log.msg('\\n------------------------------------------------------------------------------');\n log.msg(`Building entry point '${entryPoint.data.entryPoint.moduleId}'`);\n log.msg('------------------------------------------------------------------------------');\n }),\n // TypeScript sources compilation\n compileTs,\n // After TypeScript: bundling and write package\n writeBundles,\n writePackage,\n tap(graph => {\n const entryPoint = getActiveEntryPoint(graph);\n entryPoint.state = STATE_DONE;\n }),\n );\n"]}
1
+ {"version":3,"file":"entry-point.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/entry-point.transform.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAiC;AACjC,2CAA8C;AAE9C,0DAAkC;AAClC,oCAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,0BAA0B,GAAG,CACxC,SAAoB,EACpB,YAAuB,EACvB,YAAuB,EACZ,EAAE,CACb,IAAA,WAAI,EACF,IAAA,UAAG,EAAC,KAAK,CAAC,EAAE;IACV,4CAA4C;IAC5C,MAAM,UAAU,GAAG,IAAA,gCAAwB,EAAC,KAAK,CAAC,CAAC;IACnD,aAAG,CAAC,GAAG,CAAC,kFAAkF,CAAC,CAAC;IAC5F,aAAG,CAAC,GAAG,CAAC,yBAAyB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,CAAC;IACzE,aAAG,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAC;AAC5F,CAAC,CAAC;AACF,iCAAiC;AACjC,SAAS;AACT,+CAA+C;AAC/C,YAAY,EACZ,YAAY,EACZ,IAAA,UAAG,EAAC,KAAK,CAAC,EAAE;IACV,MAAM,UAAU,GAAG,IAAA,gCAAwB,EAAC,KAAK,CAAC,CAAC;IACnD,UAAU,CAAC,KAAK,GAAG,iBAAU,CAAC;AAChC,CAAC,CAAC,CACH,CAAC;AAtBS,QAAA,0BAA0B,8BAsBnC","sourcesContent":["import { pipe, tap } from 'rxjs';\nimport { STATE_DONE } from '../../graph/node';\nimport { Transform } from '../../graph/transform';\nimport log from '../../utils/log';\nimport { findEntryPointInProgress } from '../nodes';\n\n/**\n * A re-write of the `transformSources()` script that transforms an entry point from sources to distributable format.\n *\n * Sources are TypeScript source files accompanied by HTML templates and xCSS stylesheets.\n * See the Angular Package Format for a detailed description of what the distributables include.\n *\n * The current transformation pipeline can be thought of as:\n *\n * - clean\n * - compileTs\n * - downlevelTs\n * - writeBundles\n * - bundleToFesm15\n * - relocateSourceMaps\n * - writePackage\n * - copyStagedFiles (bundles, esm, dts, sourcemaps)\n * - writePackageJson\n *\n * The transformation pipeline is pluggable through the dependency injection system.\n * Sub-transformations are passed to this factory function as arguments.\n *\n * @param compileTs Transformation compiling typescript sources to ES2022 modules.\n * @param writeBundles Transformation flattening ES2022 modules to ESM2022, UMD, and minified UMD.\n * @param writePackage Transformation writing a distribution-ready `package.json` (for publishing to npm registry).\n */\nexport const entryPointTransformFactory = (\n compileTs: Transform,\n writeBundles: Transform,\n writePackage: Transform,\n): Transform =>\n pipe(\n tap(graph => {\n // Peek the first entry point from the graph\n const entryPoint = findEntryPointInProgress(graph);\n log.msg('\\n------------------------------------------------------------------------------');\n log.msg(`Building entry point '${entryPoint.data.entryPoint.moduleId}'`);\n log.msg('------------------------------------------------------------------------------');\n }),\n // TypeScript sources compilation\n compileTs,\n // After TypeScript: bundling and write package\n writeBundles,\n writePackage,\n tap(graph => {\n const entryPoint = findEntryPointInProgress(graph);\n entryPoint.state = STATE_DONE;\n }),\n );\n"]}
@@ -14,7 +14,7 @@ const fs_1 = require("../../utils/fs");
14
14
  const path_1 = require("../../utils/path");
15
15
  const nodes_1 = require("../nodes");
16
16
  const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)(async (graph) => {
17
- const entryPoint = (0, nodes_1.getActiveEntryPoint)(graph);
17
+ const entryPoint = (0, nodes_1.findEntryPointInProgress)(graph);
18
18
  const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;
19
19
  const cache = entryPoint.cache;
20
20
  const { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;
@@ -23,10 +23,7 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
23
23
  discardStdin: false,
24
24
  });
25
25
  const cacheKey = await (0, cache_1.generateKey)(ngEntryPoint.moduleId, declarationsDir, fesm2022Dir, tsConfig.options.compilationMode, (tsConfig.options.declarationMap ?? false).toString());
26
- const hash = await (0, cache_1.generateKey)([...cache.outputCache.entries()]
27
- .sort(([a], [b]) => a.localeCompare(b))
28
- .map(([p, { version }]) => `${p}:${version}`)
29
- .join(':'));
26
+ const hash = await (0, cache_1.generateKey)([...cache.outputCache.values()].map(({ version }) => version).join(':'));
30
27
  const cacheDirectory = options.cacheEnabled && options.cacheDirectory;
31
28
  if (cacheDirectory) {
32
29
  const cacheResult = await (0, cache_1.readCacheEntry)(options.cacheDirectory, cacheKey);
@@ -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;IAC9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AAc,EAAC,cAAc,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC,CAAC;AAzIQ,QAAA,qBAAqB,yBAyI7B","sourcesContent":["import { join } from 'node:path';\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;AACjC,8CAAsB;AAEtB,iEAA2F;AAC3F,qDAA4D;AAC5D,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,2CAAkD;AAClD,oCAAoD;AAqB7C,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,UAAU,GAAG,IAAA,gCAAwB,EAAC,KAAK,CAAC,CAAC;IACnD,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,aAAG,EAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAW,EAChC,YAAY,CAAC,QAAQ,EACrB,eAAe,EACf,WA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GAAG,IAAA,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;AArIQ,QAAA,qBAAqB,yBAqI7B","sourcesContent":["import { join } from 'node:path';\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 { findEntryPointInProgress } 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 = findEntryPointInProgress(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\n const hash = await generateKey([...cache.outputCache.values()].map(({ version }) => version).join(':'));\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"]}
@@ -8,6 +8,7 @@ const node_path_1 = require("node:path");
8
8
  const ora_1 = __importDefault(require("ora"));
9
9
  const tinyglobby_1 = require("tinyglobby");
10
10
  const node_1 = require("../../graph/node");
11
+ const select_1 = require("../../graph/select");
11
12
  const transform_1 = require("../../graph/transform");
12
13
  const color_1 = require("../../utils/color");
13
14
  const fs_1 = require("../../utils/fs");
@@ -18,7 +19,7 @@ const nodes_1 = require("../nodes");
18
19
  const writePackageTransform = (options) => (0, transform_1.transformFromPromise)(async (graph) => {
19
20
  const spinner = (0, ora_1.default)({ hideCursor: false, discardStdin: false });
20
21
  const entryPoints = graph.filter(nodes_1.isEntryPoint);
21
- const entryPoint = (0, nodes_1.getActiveEntryPoint)(graph);
22
+ const entryPoint = entryPoints.find(select_1.isInProgress);
22
23
  const ngEntryPoint = entryPoint.data.entryPoint;
23
24
  const ngPackageNode = (0, nodes_1.findPackageNode)(graph);
24
25
  const ngPackage = ngPackageNode.data;
@@ -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,aAAa,CAAC,IAAI,CAAC;IACrC,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IAE7C,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE,CAAC;QAC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F,KAAK,MAAM,IAAI,IAAI,6BAA6B,EAAE,CAAC;QACjD,IAAI,IAAI,IAAI,WAAW,EAAE,CAAC;YACxB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,2BAA2B,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC;IACvC,MAAM,IAAA,cAAS,EAAC,IAAA,gBAAI,EAAC,UAAU,CAAC,eAAe,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,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 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":"","sources":["../../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;;;;AAAA,yCAA8D;AAC9D,8CAAoC;AACpC,2CAAkC;AAGlC,2CAAwC;AACxC,+CAAkD;AAClD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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 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 { isInProgress } from '../../graph/select';\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, 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 = entryPoints.find(isInProgress);\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"]}
@@ -12,7 +12,6 @@ export declare function isPackage(node: Node): node is PackageNode;
12
12
  export declare function byEntryPoint(): ComplexPredicate<EntryPointNode>;
13
13
  export declare function isEntryPointInProgress(): ComplexPredicate<EntryPointNode>;
14
14
  export declare function isEntryPointPending(): ComplexPredicate<EntryPointNode>;
15
- export declare function getActiveEntryPoint(graph: BuildGraph): EntryPointNode;
16
15
  export declare function findEntryPointInProgress(graph: BuildGraph): EntryPointNode;
17
16
  export declare function findPackageNode(graph: BuildGraph): PackageNode;
18
17
  export declare function fileUrl(path: string): string;
@@ -9,7 +9,6 @@ exports.isPackage = isPackage;
9
9
  exports.byEntryPoint = byEntryPoint;
10
10
  exports.isEntryPointInProgress = isEntryPointInProgress;
11
11
  exports.isEntryPointPending = isEntryPointPending;
12
- exports.getActiveEntryPoint = getActiveEntryPoint;
13
12
  exports.findEntryPointInProgress = findEntryPointInProgress;
14
13
  exports.findPackageNode = findPackageNode;
15
14
  exports.fileUrl = fileUrl;
@@ -17,7 +16,6 @@ exports.fileUrlPath = fileUrlPath;
17
16
  exports.ngUrl = ngUrl;
18
17
  const typescript_1 = __importDefault(require("typescript"));
19
18
  const file_cache_1 = require("../file-system/file-cache");
20
- const build_graph_1 = require("../graph/build-graph");
21
19
  const node_1 = require("../graph/node");
22
20
  const select_1 = require("../graph/select");
23
21
  const angular_diagnostics_cache_1 = require("../ngc/angular-diagnostics-cache");
@@ -42,25 +40,12 @@ function isEntryPointInProgress() {
42
40
  function isEntryPointPending() {
43
41
  return (0, select_1.by)(n => isEntryPoint(n) && (0, select_1.isPending)(n));
44
42
  }
45
- function getActiveEntryPoint(graph) {
46
- if ((0, build_graph_1.isScopedBuildGraph)(graph) && isEntryPoint(graph.activeEntryPoint)) {
47
- return graph.activeEntryPoint;
48
- }
49
- return findEntryPointInProgress(graph);
50
- }
51
43
  function findEntryPointInProgress(graph) {
52
- if ((0, build_graph_1.isScopedBuildGraph)(graph) && isEntryPoint(graph.activeEntryPoint)) {
53
- return graph.activeEntryPoint;
54
- }
55
- const inProgress = graph.filter(isEntryPointInProgress());
56
- if (inProgress.length === 1) {
57
- return inProgress[0];
58
- }
59
- if (inProgress.length > 1) {
60
- const moduleIds = inProgress.map(e => e.data.entryPoint.moduleId).join(', ');
61
- throw new Error(`Multiple entry points are in progress (${moduleIds}). A ScopedBuildGraph is required.`);
44
+ const entryPoint = graph.find(isEntryPointInProgress());
45
+ if (!entryPoint) {
46
+ throw new Error('Could not find entry point in progress');
62
47
  }
63
- throw new Error('Could not find entry point in progress');
48
+ return entryPoint;
64
49
  }
65
50
  function findPackageNode(graph) {
66
51
  const packageNode = graph.find(isPackage);
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAoBA,oCAEC;AAED,8BAEC;AAED,oCAEC;AAED,wDAEC;AAED,kDAEC;AAED,kDAMC;AAED,4DAeC;AAED,0CAOC;AAED,0BAEC;AAED,kCAEC;AAED,sBAEC;AAnFD,4DAA4B;AAC5B,0DAAsD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AmB,CAAC;IAEpC,YACkB,GAAW,EAC3B,gBAA2B,EAC3B,qBAA+C;QAE/C,KAAK,CAAC,GAAG,CAAC,CAAC;QAJK,QAAG,GAAH,GAAG,CAAQ;QAM3B,IAAI,CAAC,KAAK,GAAG;YACX,gBAAgB;YAChB,uBAAuB,EAAE,IAAI,sBAAS,EAAE;YACxC,qBAAqB;YACrB,WAAW,EAAE,IAAI,GAAG,EAAE;YACtB,sBAAsB,EAAE,IAAI,mDAAuB,EAAE;YACrD,0BAA0B,EAAE,IAAI,mDAAuB,EAAE;SAC1D,CAAC;IACJ,CAAC;IAED,KAAK,CAUH;IAQF,OAAO;QACL,IAAI,CAAC,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF;AA1CD,wCA0CC;AAED,MAAa,WAAY,SAAQ,WAAI;IAC1B,IAAI,GAAG,eAAe,CAAC;IAGhC,KAAK,GAAG;QACN,gBAAgB,EAAE,IAAI,sBAAS,EAAE;QACjC,qBAAqB,EAAE,oBAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC7E,CAAC;CACH;AARD,kCAQC","sourcesContent":["import type { NgtscProgram, ParsedConfiguration } from '@angular/compiler-cli';\nimport ts from 'typescript';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph, ComplexPredicate, isScopedBuildGraph } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { by, isInProgress, isPending } from '../graph/select';\nimport { AngularDiagnosticsCache } from '../ngc/angular-diagnostics-cache';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { DestinationFiles, NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\n\nconst TYPE_NG_PACKAGE = 'application/ng-package';\nconst TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\n/** A node that can be read through the `fs` api. */\nconst URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nconst URL_PROTOCOL_NG = 'ng://';\n\nexport function isEntryPoint(node: Node): node is EntryPointNode {\n return node.type === TYPE_NG_ENTRY_POINT;\n}\n\nexport function isPackage(node: Node): node is PackageNode {\n return node.type === TYPE_NG_PACKAGE;\n}\n\nexport function byEntryPoint(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint);\n}\n\nexport function isEntryPointInProgress(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isInProgress(n));\n}\n\nexport function isEntryPointPending(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isPending(n));\n}\n\nexport function getActiveEntryPoint(graph: BuildGraph): EntryPointNode {\n if (isScopedBuildGraph(graph) && isEntryPoint(graph.activeEntryPoint)) {\n return graph.activeEntryPoint;\n }\n\n return findEntryPointInProgress(graph);\n}\n\nexport function findEntryPointInProgress(graph: BuildGraph): EntryPointNode {\n if (isScopedBuildGraph(graph) && isEntryPoint(graph.activeEntryPoint)) {\n return graph.activeEntryPoint;\n }\n\n const inProgress = graph.filter(isEntryPointInProgress());\n if (inProgress.length === 1) {\n return inProgress[0];\n }\n if (inProgress.length > 1) {\n const moduleIds = inProgress.map(e => e.data.entryPoint.moduleId).join(', ');\n throw new Error(`Multiple entry points are in progress (${moduleIds}). A ScopedBuildGraph is required.`);\n }\n\n throw new Error('Could not find entry point in progress');\n}\n\nexport function findPackageNode(graph: BuildGraph): PackageNode {\n const packageNode: PackageNode | undefined = graph.find(isPackage);\n if (!packageNode) {\n throw new Error('Could not find package node in build graph');\n }\n\n return packageNode;\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string | null {\n return url.startsWith(URL_PROTOCOL_FILE) ? url.slice(URL_PROTOCOL_FILE.length) : null;\n}\n\nexport function ngUrl(path: string): string {\n return `${URL_PROTOCOL_NG}${path}`;\n}\n\nexport type OutputFileCache = Map<string, { version?: string; content: string }>;\n\nexport class EntryPointNode extends Node {\n readonly type = TYPE_NG_ENTRY_POINT;\n\n constructor(\n public readonly url: string,\n sourcesFileCache: FileCache,\n moduleResolutionCache: ts.ModuleResolutionCache,\n ) {\n super(url);\n\n this.cache = {\n sourcesFileCache,\n analyseSourcesFileCache: new FileCache(),\n moduleResolutionCache,\n outputCache: new Map(),\n angularDiagnosticCache: new AngularDiagnosticsCache(),\n declarationDiagnosticCache: new AngularDiagnosticsCache(),\n };\n }\n\n cache?: {\n outputCache: OutputFileCache;\n sourcesFileCache: FileCache;\n analyseSourcesFileCache: FileCache;\n moduleResolutionCache: ts.ModuleResolutionCache;\n stylesheetProcessor?: StylesheetProcessor;\n oldNgtscProgram?: NgtscProgram;\n oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n angularDiagnosticCache: AngularDiagnosticsCache;\n declarationDiagnosticCache: AngularDiagnosticsCache;\n };\n\n declare data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n\n dispose(): void {\n this.cache?.stylesheetProcessor?.destroy();\n this.cache = undefined;\n }\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n declare data: NgPackage;\n\n cache = {\n sourcesFileCache: new FileCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n };\n}\n"]}
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAoBA,oCAEC;AAED,8BAEC;AAED,oCAEC;AAED,wDAEC;AAED,kDAEC;AAED,4DAOC;AAED,0CAOC;AAED,0BAEC;AAED,kCAEC;AAED,sBAEC;AAnED,4DAA4B;AAC5B,0DAAsD;AAEtD,wCAAqC;AACrC,4CAA8D;AAC9D,gFAA2E;AAK3E,MAAM,eAAe,GAAG,wBAAwB,CAAC;AACjD,MAAM,mBAAmB,GA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compiler-cli';\nimport ts from 'typescript';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph, ComplexPredicate } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { by, isInProgress, isPending } from '../graph/select';\nimport { AngularDiagnosticsCache } from '../ngc/angular-diagnostics-cache';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { DestinationFiles, NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\n\nconst TYPE_NG_PACKAGE = 'application/ng-package';\nconst TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\n/** A node that can be read through the `fs` api. */\nconst URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nconst URL_PROTOCOL_NG = 'ng://';\n\nexport function isEntryPoint(node: Node): node is EntryPointNode {\n return node.type === TYPE_NG_ENTRY_POINT;\n}\n\nexport function isPackage(node: Node): node is PackageNode {\n return node.type === TYPE_NG_PACKAGE;\n}\n\nexport function byEntryPoint(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint);\n}\n\nexport function isEntryPointInProgress(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isInProgress(n));\n}\n\nexport function isEntryPointPending(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isPending(n));\n}\n\nexport function findEntryPointInProgress(graph: BuildGraph): EntryPointNode {\n const entryPoint = graph.find(isEntryPointInProgress());\n if (!entryPoint) {\n throw new Error('Could not find entry point in progress');\n }\n\n return entryPoint;\n}\n\nexport function findPackageNode(graph: BuildGraph): PackageNode {\n const packageNode: PackageNode | undefined = graph.find(isPackage);\n if (!packageNode) {\n throw new Error('Could not find package node in build graph');\n }\n\n return packageNode;\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string | null {\n return url.startsWith(URL_PROTOCOL_FILE) ? url.slice(URL_PROTOCOL_FILE.length) : null;\n}\n\nexport function ngUrl(path: string): string {\n return `${URL_PROTOCOL_NG}${path}`;\n}\n\nexport type OutputFileCache = Map<string, { version?: string; content: string }>;\n\nexport class EntryPointNode extends Node {\n readonly type = TYPE_NG_ENTRY_POINT;\n\n constructor(\n public readonly url: string,\n sourcesFileCache: FileCache,\n moduleResolutionCache: ts.ModuleResolutionCache,\n ) {\n super(url);\n\n this.cache = {\n sourcesFileCache,\n analyseSourcesFileCache: new FileCache(),\n moduleResolutionCache,\n outputCache: new Map(),\n angularDiagnosticCache: new AngularDiagnosticsCache(),\n declarationDiagnosticCache: new AngularDiagnosticsCache(),\n };\n }\n\n cache?: {\n outputCache: OutputFileCache;\n sourcesFileCache: FileCache;\n analyseSourcesFileCache: FileCache;\n moduleResolutionCache: ts.ModuleResolutionCache;\n stylesheetProcessor?: StylesheetProcessor;\n oldNgtscProgram?: NgtscProgram;\n oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n angularDiagnosticCache: AngularDiagnosticsCache;\n declarationDiagnosticCache: AngularDiagnosticsCache;\n };\n\n declare data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n\n dispose(): void {\n this.cache?.stylesheetProcessor?.destroy();\n this.cache = undefined;\n }\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n declare data: NgPackage;\n\n cache = {\n sourcesFileCache: new FileCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n };\n}\n"]}
@@ -5,10 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.packageTransformFactory = void 0;
7
7
  const dependency_graph_1 = require("dependency-graph");
8
- const node_os_1 = require("node:os");
9
8
  const rxjs_1 = require("rxjs");
10
9
  const file_watcher_1 = require("../file-system/file-watcher");
11
- const build_graph_1 = require("../graph/build-graph");
12
10
  const node_1 = require("../graph/node");
13
11
  const sass_language_1 = require("../styles/stylesheets/sass-language");
14
12
  const color_1 = require("../utils/color");
@@ -110,161 +108,40 @@ const buildTransformFactory = (project, options, analyseSourcesTransform, entryP
110
108
  scheduleEntryPoints(entryPointTransform, options), (0, rxjs_1.tap)(() => printBuiltAngularPackage(ngPkg, startTime)));
111
109
  }));
112
110
  };
113
- const scheduleEntryPoints = (epTransform, options) => (0, rxjs_1.pipe)((0, rxjs_1.concatMap)(graph => new rxjs_1.Observable(subscriber => {
111
+ const scheduleEntryPoints = (epTransform, options) => (0, rxjs_1.pipe)((0, rxjs_1.concatMap)(graph => {
114
112
  // Calculate node/dependency depth and determine build order
115
113
  const depGraph = new dependency_graph_1.DepGraph({ circular: false });
116
- const entryPoints = new Map();
117
114
  for (const node of graph.values()) {
118
115
  if (!(0, nodes_1.isEntryPoint)(node)) {
119
116
  continue;
120
117
  }
121
118
  // Remove `ng://` prefix for better error messages
122
- const from = node.url.startsWith('ng://') ? node.url.slice(5) : node.url;
123
- entryPoints.set(from, node);
119
+ const from = node.url.substring(5);
124
120
  depGraph.addNode(from);
125
121
  for (const dep of node.dependents) {
126
122
  if (!(0, nodes_1.isEntryPoint)(dep)) {
127
123
  continue;
128
124
  }
129
- const to = dep.url.startsWith('ng://') ? dep.url.slice(5) : dep.url;
125
+ const to = dep.url.substring(5);
130
126
  depGraph.addNode(to);
131
127
  depGraph.addDependency(from, to);
132
128
  }
133
129
  }
134
- // Topological sort will throw a DependencyCycleError if cycles exist
135
- const overallOrder = depGraph.overallOrder();
136
- const pending = new Set();
137
- for (const id of overallOrder) {
138
- const ep = entryPoints.get(id);
139
- if (ep && ep.state !== node_1.STATE_DONE) {
140
- pending.add(id);
141
- }
142
- }
143
- if (pending.size === 0) {
144
- subscriber.next(graph);
145
- subscriber.complete();
146
- return;
147
- }
148
- const inDegree = new Map();
149
- const readyQueue = [];
150
- for (const id of pending) {
151
- const directDeps = depGraph.directDependenciesOf(id);
152
- let pendingDepsCount = 0;
153
- for (const dep of directDeps) {
154
- if (pending.has(dep)) {
155
- pendingDepsCount++;
156
- }
157
- }
158
- inDegree.set(id, pendingDepsCount);
159
- if (pendingDepsCount === 0) {
160
- readyQueue.push(id);
161
- }
162
- }
163
- const maxConcurrency = Math.max(1, Math.min((0, node_os_1.availableParallelism)() - 1, 8));
164
- let activeCount = 0;
165
- let buildError = null;
166
- let isCancelled = false;
167
- const activeSubscriptions = new Set();
168
- const toError = (err) => {
169
- if (err instanceof Error) {
170
- return err;
171
- }
172
- if (typeof err === 'string') {
173
- return new Error(err);
174
- }
175
- if (err &&
176
- typeof err === 'object' &&
177
- 'message' in err &&
178
- typeof err.message === 'string') {
179
- return new Error(err.message);
180
- }
181
- return new Error('Build error');
182
- };
183
- const next = () => {
184
- if (isCancelled) {
185
- return;
186
- }
187
- if (buildError) {
188
- if (activeCount === 0) {
189
- subscriber.error(toError(buildError));
190
- }
191
- return;
192
- }
193
- if (pending.size === 0 && activeCount === 0) {
194
- subscriber.next(graph);
195
- subscriber.complete();
196
- return;
197
- }
198
- if (activeCount === 0 && readyQueue.length === 0 && pending.size > 0) {
199
- const pendingIds = [...pending].join(', ');
200
- subscriber.error(new Error(`Deadlock detected: unresolved dependencies for [${pendingIds}]`));
201
- return;
202
- }
203
- while (activeCount < maxConcurrency && readyQueue.length > 0) {
204
- const id = readyQueue.shift();
205
- if (!id) {
206
- break;
207
- }
208
- const ep = entryPoints.get(id);
209
- if (!ep) {
210
- buildError = new Error(`Entry point node not found for '${id}'`);
211
- readyQueue.length = 0;
212
- if (activeCount === 0) {
213
- subscriber.error(toError(buildError));
214
- }
215
- return;
216
- }
217
- activeCount++;
218
- const scopedGraph = new build_graph_1.ScopedBuildGraph(graph, ep);
219
- const run$ = (0, rxjs_1.of)(scopedGraph).pipe((0, rxjs_1.tap)(() => {
220
- ep.state = node_1.STATE_IN_PROGRESS;
221
- }), epTransform, (0, rxjs_1.catchError)(err => {
222
- ep.state = node_1.STATE_ERROR;
223
- throw err;
224
- }), (0, rxjs_1.finalize)(() => {
225
- if (!options.watch) {
226
- ep.dispose();
227
- }
228
- }));
229
- const sub = run$.subscribe({
230
- error: err => {
231
- activeSubscriptions.delete(sub);
232
- activeCount--;
233
- if (!buildError) {
234
- buildError = err;
235
- readyQueue.length = 0;
236
- }
237
- next();
238
- },
239
- complete: () => {
240
- activeSubscriptions.delete(sub);
241
- activeCount--;
242
- pending.delete(id);
243
- for (const depId of depGraph.directDependantsOf(id)) {
244
- if (pending.has(depId)) {
245
- const remaining = (inDegree.get(depId) ?? 1) - 1;
246
- inDegree.set(depId, remaining);
247
- if (remaining === 0) {
248
- readyQueue.push(depId);
249
- }
250
- }
251
- }
252
- next();
253
- },
254
- });
255
- activeSubscriptions.add(sub);
256
- }
257
- };
258
- next();
259
- return () => {
260
- isCancelled = true;
261
- readyQueue.length = 0;
262
- for (const activeSub of activeSubscriptions) {
263
- activeSub.unsubscribe();
264
- }
265
- activeSubscriptions.clear();
266
- };
267
- })));
130
+ // The array index is the depth.
131
+ const groups = depGraph.overallOrder().map(nodes_1.ngUrl);
132
+ // Build entry points with lower depth values first.
133
+ return (0, rxjs_1.from)(groups).pipe((0, rxjs_1.map)((epUrl) => graph.find((0, nodes_1.byEntryPoint)().and(ep => ep.url === epUrl))), (0, rxjs_1.filter)((entryPoint) => entryPoint.state !== node_1.STATE_DONE), (0, rxjs_1.concatMap)(ep => (0, rxjs_1.of)(ep).pipe(
134
+ // Mark the entry point as 'in-progress'
135
+ (0, rxjs_1.tap)(entryPoint => (entryPoint.state = node_1.STATE_IN_PROGRESS)), (0, rxjs_1.map)(() => graph), epTransform, (0, rxjs_1.catchError)(err => {
136
+ ep.state = node_1.STATE_ERROR;
137
+ throw err;
138
+ }), (0, rxjs_1.finalize)(() => {
139
+ if (!options.watch) {
140
+ ep.dispose();
141
+ }
142
+ }))), (0, rxjs_1.takeLast)(1), // don't use last as sometimes it this will cause 'no elements in sequence',
143
+ (0, rxjs_1.defaultIfEmpty)(graph));
144
+ }));
268
145
  function printBuiltAngularPackage(ngPackage, startTime) {
269
146
  log_1.default.success('\n------------------------------------------------------------------------------');
270
147
  log_1.default.success(`Built Angular Package
@@ -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,I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';\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,+BAqBc;AACd,8DAAyG;AAEzG,wCAAgG;AAEhG,uEAA6E;AAC7E,0CAAwC;AACxC,oCAAoC;AACpC,uDAA+B;AAC/B,2DAAuD;AACvD,mCAQiB;AAGjB;;;;;;;;;;;;;;;GAeG;AACI,MAAM,uBAAuB,GAClC,CACE,OAAe,EACf,OAAyB,EACzB,qBAAgC,EAChC,uBAAkC,EAClC,mBAA8B,EAC9B,EAAE,CACJ,CAAC,OAA+B,EAA0B,E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from 'dependency-graph';\nimport {\n EMPTY,\n NEVER,\n Observable,\n catchError,\n concatMap,\n debounceTime,\n defaultIfEmpty,\n filter,\n finalize,\n from,\n last,\n map,\n of as observableOf,\n of,\n pipe,\n repeat,\n startWith,\n switchMap,\n takeLast,\n tap,\n} from 'rxjs';\nimport { createFileWatch, invalidateEntryPointsAndCacheOnFileChange } from '../file-system/file-watcher';\nimport { BuildGraph } 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 {\n EntryPointNode,\n PackageNode,\n byEntryPoint,\n findPackageNode,\n isEntryPoint,\n isEntryPointPending,\n ngUrl,\n} 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(graph => {\n // Calculate node/dependency depth and determine build order\n const depGraph = new DepGraph({ circular: false });\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.substring(5);\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.substring(5);\n depGraph.addNode(to);\n depGraph.addDependency(from, to);\n }\n }\n\n // The array index is the depth.\n const groups = depGraph.overallOrder().map(ngUrl);\n\n // Build entry points with lower depth values first.\n return from(groups).pipe(\n map((epUrl: string): EntryPointNode => graph.find(byEntryPoint().and(ep => ep.url === epUrl))),\n filter((entryPoint: EntryPointNode): boolean => entryPoint.state !== STATE_DONE),\n concatMap(ep =>\n observableOf(ep).pipe(\n // Mark the entry point as 'in-progress'\n tap(entryPoint => (entryPoint.state = STATE_IN_PROGRESS)),\n map(() => graph),\n epTransform,\n catchError(err => {\n ep.state = STATE_ERROR;\n\n throw err;\n }),\n finalize(() => {\n if (!options.watch) {\n ep.dispose();\n }\n }),\n ),\n ),\n takeLast(1), // don't use last as sometimes it this will cause 'no elements in sequence',\n defaultIfEmpty(graph),\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"]}
@@ -16,7 +16,7 @@ function hasEmitBuildInfo(builder) {
16
16
  async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, options, extraOptions, stylesheetProcessor) {
17
17
  const { cacheDirectory, watch, cacheEnabled } = options;
18
18
  const tsConfigOptions = { ...tsConfig.options, ...extraOptions };
19
- const entryPoint = (0, nodes_1.getActiveEntryPoint)(graph);
19
+ const entryPoint = (0, nodes_1.findEntryPointInProgress)(graph);
20
20
  const ngPackageNode = (0, nodes_1.findPackageNode)(graph);
21
21
  const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;
22
22
  const cacheDir = cacheEnabled && cacheDirectory;
@@ -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,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CAAC;IACrF,CAAC,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QAClD,IAAI,UAAU,CAAC,iBAAiB,IAAI,aAAa,CAAC,GAAG,CAAC,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,gDAiNC;AAnOD,wDAA8G;AAC9G,yCAAiC;AACjC,4DAA4B;AAE5B,+CAAgF;AAGhF,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,gCAAwB,EAAC,KAAK,CAAC,CAAC;IACnD,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,e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AE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,IAAA,gCAAiB,EAAC,gBAAgB,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC;IAEhE,MAAM,SAAS,GAAyB,CAAC,QAAQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE;QACnG,IAAI,WAAW,EAAE,CAAC;YAChB,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACrC,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;oBAClC,eAAe,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;gBAC1E,CAAC;YACH,CAAC;QACH,CAAC;QAED,cAAc,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACrF,CAAC,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QAClD,IAAI,UAAU,CAAC,iBAAiB,IAAI,aAAa,CAAC,GAAG,CAAC,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 { findEntryPointInProgress, findPackageNode } 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 = findEntryPointInProgress(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"]}
@@ -10,20 +10,18 @@ const esbuild_1 = require("esbuild");
10
10
  const node_assert_1 = __importDefault(require("node:assert"));
11
11
  const node_path_1 = require("node:path");
12
12
  const typescript_1 = __importDefault(require("typescript"));
13
- const build_graph_1 = require("../graph/build-graph");
14
13
  const node_1 = require("../graph/node");
15
14
  const nodes_1 = require("../ng-package/nodes");
16
15
  const log_1 = require("../utils/log");
17
16
  const path_1 = require("../utils/path");
18
17
  function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionCache, stylesheetProcessor, inlineStyleLanguage, sourcesFileCache = entryPoint.cache.sourcesFileCache) {
19
18
  const compilerHost = typescript_1.default.createIncrementalCompilerHost(compilerOptions);
20
- const rootGraph = (0, build_graph_1.isScopedBuildGraph)(graph) ? graph.parentGraph : graph;
21
19
  const getNode = (fileName) => {
22
20
  const nodeUri = (0, nodes_1.fileUrl)((0, path_1.ensureUnixPath)(fileName));
23
- let node = rootGraph.get(nodeUri);
21
+ let node = graph.get(nodeUri);
24
22
  if (!node) {
25
23
  node = new node_1.Node(nodeUri);
26
- rootGraph.put(node);
24
+ graph.put(node);
27
25
  }
28
26
  return node;
29
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;AAeA,8CAsMC;AAED,oEAaC;AAnOD,mCAAoC;AACpC,qCAAyC;AACzC,8DAAiC;AACjC,yCAAsD;AACtD,4DAA4B;AAG5B,sDAAsE;AACtE,wCAAqC;AACrC,+CAA8D;AAE9D,sCAA2C;AAC3C,wCAA+C;AAE/C,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAgC,EAChC,qBAA+C,EAC/C,mBAAyC,EACzC,mBAA4D,EAC5D,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB;IAE/D,MAAM,YAAY,GAAG,oBAAE,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;IACvE,MAAM,SAAS,GAAG,IAAA,gCAAkB,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;IAExE,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAElC,IAAI,CAAC,IA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AC;YAC/B,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,4BAA4B,CAAC,OAAmB;IAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAClD,OAAO,CAAC,cAAc,GAAG,UAAU,GAAG,UAAU;QAC9C,MAAM,KAAK,GAAsD,kBAAkB,CAAC,GAAG,UAAU,CAAC,CAAC;QAEnG,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC/B,IAAI,CAAC,OAAO,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CompilerHost, CompilerOptions } from '@angular/compiler-cli';\nimport { createHash } from 'crypto';\nimport { formatMessages } from 'esbuild';\nimport assert from 'node:assert';\nimport { dirname, extname, resolve } from 'node:path';\nimport ts from 'typescript';\nimport { NgPackageConfig } from '../../ng-package.schema';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph, isScopedBuildGraph } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { error, warn } from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'],\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n): CompilerHost {\n const compilerHost = ts.createIncrementalCompilerHost(compilerOptions);\n const rootGraph = isScopedBuildGraph(graph) ? graph.parentGraph : graph;\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = rootGraph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n rootGraph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n return {\n ...compilerHost,\n\n // Set the parsing mode to the same as TS 5.3+ default for tsc. This provides a parse\n // performance improvement by skipping non-type related JSDoc parsing.\n jsDocParsingMode: ts.JSDocParsingMode.ParseForTypeErrors,\n\n // ts specific\n getModuleResolutionCache: () => moduleResolutionCache,\n\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists(fileName);\n }\n\n return cache.exists;\n },\n\n getSourceFile: (fileName, languageVersion, onError, shouldCreateNewSourceFile, ...parameters) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n\n if (shouldCreateNewSourceFile || !cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile(fileName, languageVersion, onError, true, ...parameters);\n }\n\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.includes('.ngtypecheck.')) {\n return;\n }\n\n const extension = extname(fileName);\n if (!sourceFiles?.length && extension === '.tsbuildinfo') {\n // Save builder info contents to specified location\n compilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n\n return;\n }\n\n assert(sourceFiles?.length === 1, 'Invalid TypeScript program emit for ' + fileName);\n const outputCache = entryPoint.cache.outputCache;\n if (outputCache.get(fileName)?.content === data) {\n return;\n }\n\n outputCache.set(fileName, {\n content: data,\n version: createHash('sha256').update(data).digest('hex'),\n });\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile(fileName);\n }\n\n return cache.content;\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = resolve(dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: async (fileName: string): Promise<string> => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n if (!compilerHost.fileExists(fileName)) {\n throw new Error(`Cannot read file ${fileName}.`);\n }\n\n if (/(?:html?|svg)$/.test(extname(fileName))) {\n // template\n cache.content = compilerHost.readFile(fileName);\n } else {\n // stylesheet\n if (!stylesheetProcessor) {\n throw new Error('stylesheetProcessor is not available for processing stylesheets');\n }\n const {\n referencedFiles,\n contents,\n errors: esbuildErrors,\n warnings: esBuildWarnings,\n } = await stylesheetProcessor.bundleFile(fileName);\n const node = getNode(fileName);\n const depNodes = [...(referencedFiles ?? [])].map(getNode).filter(n => n !== node);\n node.dependsOn(depNodes);\n\n for (const n of node.dependees) {\n if (n.url.endsWith('.ts')) {\n n.dependsOn(depNodes);\n }\n }\n\n if (esBuildWarnings?.length) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length) {\n (await formatMessages(esbuildErrors, { kind: 'error' })).forEach(msg => error(msg));\n\n throw new Error(`An error has occuried while processing ${fileName}.`);\n }\n\n return contents;\n }\n\n cache.exists = true;\n }\n\n return cache.content ?? '';\n },\n transformResource: async (data, context) => {\n const { containingFile, resourceFile, type } = context;\n\n if (resourceFile || type !== 'style') {\n return null;\n }\n\n if (inlineStyleLanguage) {\n const {\n contents,\n referencedFiles,\n errors: esbuildErrors,\n warnings: esBuildWarnings,\n } = await stylesheetProcessor.bundleInline(\n data,\n containingFile,\n containingFile.endsWith('.html') ? 'css' : inlineStyleLanguage,\n );\n\n const node = getNode(containingFile);\n node.dependsOn([...referencedFiles].map(getNode));\n\n if (esBuildWarnings?.length) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length) {\n (await formatMessages(esbuildErrors, { kind: 'error' })).forEach(msg => error(msg));\n\n throw new Error(`An error has occuried while processing ${containingFile}.`);\n }\n\n return { content: contents };\n }\n\n return null;\n },\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n if (file.version === undefined) {\n file.version = createHash('sha256').update(file.text).digest('hex');\n }\n }\n\n return files;\n };\n}\n"]}
1
+ {"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;AAeA,8CAqMC;AAED,oEAaC;AAlOD,mCAAoC;AACpC,qCAAyC;AACzC,8DAAiC;AACjC,yCAAsD;AACtD,4DAA4B;AAI5B,wCAAqC;AACrC,+CAA8D;AAE9D,sCAA2C;AAC3C,wCAA+C;AAE/C,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAgC,EAChC,qBAA+C,EAC/C,mBAAyC,EACzC,mBAA4D,EAC5D,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB;IAE/D,MAAM,YAAY,GAAG,oBAAE,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QA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AE,QAAQ,EAAE,CAAC;YAC/B,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,4BAA4B,CAAC,OAAmB;IAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAClD,OAAO,CAAC,cAAc,GAAG,UAAU,GAAG,UAAU;QAC9C,MAAM,KAAK,GAAsD,kBAAkB,CAAC,GAAG,UAAU,CAAC,CAAC;QAEnG,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC/B,IAAI,CAAC,OAAO,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CompilerHost, CompilerOptions } from '@angular/compiler-cli';\nimport { createHash } from 'crypto';\nimport { formatMessages } from 'esbuild';\nimport assert from 'node:assert';\nimport { dirname, extname, resolve } from 'node:path';\nimport ts from 'typescript';\nimport { NgPackageConfig } from '../../ng-package.schema';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { error, warn } from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'],\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n): CompilerHost {\n const compilerHost = ts.createIncrementalCompilerHost(compilerOptions);\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n return {\n ...compilerHost,\n\n // Set the parsing mode to the same as TS 5.3+ default for tsc. This provides a parse\n // performance improvement by skipping non-type related JSDoc parsing.\n jsDocParsingMode: ts.JSDocParsingMode.ParseForTypeErrors,\n\n // ts specific\n getModuleResolutionCache: () => moduleResolutionCache,\n\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists(fileName);\n }\n\n return cache.exists;\n },\n\n getSourceFile: (fileName, languageVersion, onError, shouldCreateNewSourceFile, ...parameters) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n\n if (shouldCreateNewSourceFile || !cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile(fileName, languageVersion, onError, true, ...parameters);\n }\n\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.includes('.ngtypecheck.')) {\n return;\n }\n\n const extension = extname(fileName);\n if (!sourceFiles?.length && extension === '.tsbuildinfo') {\n // Save builder info contents to specified location\n compilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n\n return;\n }\n\n assert(sourceFiles?.length === 1, 'Invalid TypeScript program emit for ' + fileName);\n const outputCache = entryPoint.cache.outputCache;\n if (outputCache.get(fileName)?.content === data) {\n return;\n }\n\n outputCache.set(fileName, {\n content: data,\n version: createHash('sha256').update(data).digest('hex'),\n });\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile(fileName);\n }\n\n return cache.content;\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = resolve(dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: async (fileName: string): Promise<string> => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n if (!compilerHost.fileExists(fileName)) {\n throw new Error(`Cannot read file ${fileName}.`);\n }\n\n if (/(?:html?|svg)$/.test(extname(fileName))) {\n // template\n cache.content = compilerHost.readFile(fileName);\n } else {\n // stylesheet\n if (!stylesheetProcessor) {\n throw new Error('stylesheetProcessor is not available for processing stylesheets');\n }\n const {\n referencedFiles,\n contents,\n errors: esbuildErrors,\n warnings: esBuildWarnings,\n } = await stylesheetProcessor.bundleFile(fileName);\n const node = getNode(fileName);\n const depNodes = [...(referencedFiles ?? [])].map(getNode).filter(n => n !== node);\n node.dependsOn(depNodes);\n\n for (const n of node.dependees) {\n if (n.url.endsWith('.ts')) {\n n.dependsOn(depNodes);\n }\n }\n\n if (esBuildWarnings?.length) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length) {\n (await formatMessages(esbuildErrors, { kind: 'error' })).forEach(msg => error(msg));\n\n throw new Error(`An error has occuried while processing ${fileName}.`);\n }\n\n return contents;\n }\n\n cache.exists = true;\n }\n\n return cache.content ?? '';\n },\n transformResource: async (data, context) => {\n const { containingFile, resourceFile, type } = context;\n\n if (resourceFile || type !== 'style') {\n return null;\n }\n\n if (inlineStyleLanguage) {\n const {\n contents,\n referencedFiles,\n errors: esbuildErrors,\n warnings: esBuildWarnings,\n } = await stylesheetProcessor.bundleInline(\n data,\n containingFile,\n containingFile.endsWith('.html') ? 'css' : inlineStyleLanguage,\n );\n\n const node = getNode(containingFile);\n node.dependsOn([...referencedFiles].map(getNode));\n\n if (esBuildWarnings?.length) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length) {\n (await formatMessages(esbuildErrors, { kind: 'error' })).forEach(msg => error(msg));\n\n throw new Error(`An error has occuried while processing ${containingFile}.`);\n }\n\n return { content: contents };\n }\n\n return null;\n },\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n if (file.version === undefined) {\n file.version = createHash('sha256').update(file.text).digest('hex');\n }\n }\n\n return files;\n };\n}\n"]}