@angular/build 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.
Files changed (123) hide show
  1. package/package.json +13 -13
  2. package/src/builders/application/build-action.js +2 -2
  3. package/src/builders/application/build-action.js.map +1 -1
  4. package/src/builders/application/index.js +8 -31
  5. package/src/builders/application/index.js.map +1 -1
  6. package/src/builders/application/options.d.ts +1 -3
  7. package/src/builders/application/options.js +1 -1
  8. package/src/builders/application/options.js.map +1 -1
  9. package/src/builders/application/results.d.ts +1 -1
  10. package/src/builders/dev-server/vite/utils.js +1 -1
  11. package/src/builders/dev-server/vite/utils.js.map +1 -1
  12. package/src/builders/extract-i18n/application-extraction.js +2 -1
  13. package/src/builders/extract-i18n/application-extraction.js.map +1 -1
  14. package/src/builders/karma/assets-middleware.js +1 -1
  15. package/src/builders/karma/assets-middleware.js.map +1 -1
  16. package/src/builders/library/builder-state.d.ts +115 -0
  17. package/src/builders/library/builder-state.js +282 -0
  18. package/src/builders/library/builder-state.js.map +1 -0
  19. package/src/builders/library/builder.js +101 -89
  20. package/src/builders/library/builder.js.map +1 -1
  21. package/src/builders/library/execution-result.d.ts +35 -0
  22. package/src/builders/library/execution-result.js +67 -0
  23. package/src/builders/library/execution-result.js.map +1 -0
  24. package/src/builders/library/index.d.ts +1 -1
  25. package/src/builders/library/index.js.map +1 -1
  26. package/src/builders/library/options.d.ts +9 -0
  27. package/src/builders/library/options.js +29 -14
  28. package/src/builders/library/options.js.map +1 -1
  29. package/src/builders/library/pipeline/assets.d.ts +3 -3
  30. package/src/builders/library/pipeline/assets.js +12 -16
  31. package/src/builders/library/pipeline/assets.js.map +1 -1
  32. package/src/builders/library/pipeline/build-action.d.ts +11 -24
  33. package/src/builders/library/pipeline/build-action.js +76 -125
  34. package/src/builders/library/pipeline/build-action.js.map +1 -1
  35. package/src/builders/library/pipeline/bundler.d.ts +3 -3
  36. package/src/builders/library/pipeline/bundler.js +55 -33
  37. package/src/builders/library/pipeline/bundler.js.map +1 -1
  38. package/src/builders/library/pipeline/compilation.d.ts +7 -26
  39. package/src/builders/library/pipeline/compilation.js +59 -69
  40. package/src/builders/library/pipeline/compilation.js.map +1 -1
  41. package/src/builders/library/pipeline/entry-points.d.ts +26 -6
  42. package/src/builders/library/pipeline/entry-points.js +82 -21
  43. package/src/builders/library/pipeline/entry-points.js.map +1 -1
  44. package/src/builders/library/pipeline/package-manifests.d.ts +2 -1
  45. package/src/builders/library/pipeline/package-manifests.js +50 -1
  46. package/src/builders/library/pipeline/package-manifests.js.map +1 -1
  47. package/src/builders/library/pipeline/stylesheet-bundler.d.ts +4 -1
  48. package/src/builders/library/pipeline/stylesheet-bundler.js +1 -1
  49. package/src/builders/library/pipeline/stylesheet-bundler.js.map +1 -1
  50. package/src/builders/library/pipeline/utils.d.ts +19 -11
  51. package/src/builders/library/pipeline/utils.js +27 -11
  52. package/src/builders/library/pipeline/utils.js.map +1 -1
  53. package/src/builders/library/schema.json +2 -4
  54. package/src/builders/library/types.d.ts +62 -22
  55. package/src/builders/unit-test/runners/vitest/executor.js +0 -5
  56. package/src/builders/unit-test/runners/vitest/executor.js.map +1 -1
  57. package/src/builders/unit-test/runners/vitest/plugins.js +13 -1
  58. package/src/builders/unit-test/runners/vitest/plugins.js.map +1 -1
  59. package/src/builders/unit-test/test-discovery.js +4 -2
  60. package/src/builders/unit-test/test-discovery.js.map +1 -1
  61. package/src/private.d.ts +1 -1
  62. package/src/private.js +3 -3
  63. package/src/private.js.map +1 -1
  64. package/src/tools/angular/angular-host.d.ts +1 -1
  65. package/src/tools/angular/angular-host.js +5 -2
  66. package/src/tools/angular/angular-host.js.map +1 -1
  67. package/src/tools/angular/compilation/angular-compilation.d.ts +1 -0
  68. package/src/tools/angular/compilation/angular-compilation.js.map +1 -1
  69. package/src/tools/angular/compilation/aot-compilation.js +325 -80
  70. package/src/tools/angular/compilation/aot-compilation.js.map +1 -1
  71. package/src/tools/angular/compilation/compiler-options.js +4 -1
  72. package/src/tools/angular/compilation/compiler-options.js.map +1 -1
  73. package/src/tools/angular/compilation/jit-compilation.js +5 -4
  74. package/src/tools/angular/compilation/jit-compilation.js.map +1 -1
  75. package/src/tools/angular/compilation/parallel-worker.js +1 -0
  76. package/src/tools/angular/compilation/parallel-worker.js.map +1 -1
  77. package/src/tools/angular/compilation/typescript-compilation.d.ts +2 -0
  78. package/src/tools/angular/compilation/typescript-compilation.js +44 -5
  79. package/src/tools/angular/compilation/typescript-compilation.js.map +1 -1
  80. package/src/tools/esbuild/bundler-context.js +5 -1
  81. package/src/tools/esbuild/bundler-context.js.map +1 -1
  82. package/src/tools/esbuild/persistent-load-result-cache.js +2 -4
  83. package/src/tools/esbuild/persistent-load-result-cache.js.map +1 -1
  84. package/src/tools/esbuild/utils.d.ts +1 -2
  85. package/src/tools/esbuild/utils.js +0 -13
  86. package/src/tools/esbuild/utils.js.map +1 -1
  87. package/src/tools/sass/rebasing-importer.d.ts +1 -1
  88. package/src/tools/sass/rebasing-importer.js +6 -3
  89. package/src/tools/sass/rebasing-importer.js.map +1 -1
  90. package/src/tools/vite/middlewares/assets-middleware.js +1 -1
  91. package/src/tools/vite/middlewares/assets-middleware.js.map +1 -1
  92. package/src/utils/concurrency.d.ts +4 -0
  93. package/src/utils/concurrency.js +5 -0
  94. package/src/utils/concurrency.js.map +1 -1
  95. package/src/utils/delete-output-dir.js +3 -2
  96. package/src/utils/delete-output-dir.js.map +1 -1
  97. package/src/utils/disk-files.d.ts +30 -0
  98. package/src/utils/disk-files.js +68 -0
  99. package/src/utils/disk-files.js.map +1 -0
  100. package/src/utils/index-file/nonce.d.ts +2 -1
  101. package/src/utils/index-file/nonce.js +22 -4
  102. package/src/utils/index-file/nonce.js.map +1 -1
  103. package/src/utils/normalize-asset-patterns.d.ts +18 -3
  104. package/src/utils/normalize-asset-patterns.js +34 -67
  105. package/src/utils/normalize-asset-patterns.js.map +1 -1
  106. package/src/utils/normalize-cache.js +2 -2
  107. package/src/utils/normalize-cache.js.map +1 -1
  108. package/src/utils/postcss-configuration.d.ts +2 -2
  109. package/src/utils/postcss-configuration.js +3 -3
  110. package/src/utils/postcss-configuration.js.map +1 -1
  111. package/src/utils/resolve-assets.js +28 -9
  112. package/src/utils/resolve-assets.js.map +1 -1
  113. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +1 -1
  114. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +3 -3
  115. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js.map +1 -1
  116. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +3 -2
  117. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js.map +1 -1
  118. package/src/utils/test-files.js +5 -57
  119. package/src/utils/test-files.js.map +1 -1
  120. package/src/utils/watcher.d.ts +53 -0
  121. package/src/utils/watcher.js +404 -76
  122. package/src/utils/watcher.js.map +1 -1
  123. package/src/builders/library/pipeline/types.d.ts +0 -54
@@ -0,0 +1,282 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.BuilderState = void 0;
11
+ const path_1 = require("../../utils/path");
12
+ const execution_result_1 = require("./execution-result");
13
+ /**
14
+ * Encapsulates incremental compilation state, transitive resource reference tracking,
15
+ * watched compilation file tracking, and execution results across watch-mode rebuilds.
16
+ */
17
+ class BuilderState {
18
+ #referencingFiles = new Map();
19
+ #referencedByFile = new Map();
20
+ #watchedCompilationFiles = new Set();
21
+ #pendingCompilationFiles = new Set();
22
+ #executionResult = new execution_result_1.ExecutionResult();
23
+ #singleProgramCache;
24
+ #compilationMode;
25
+ /** Map of entry point names to their previous bundle results. */
26
+ previousBundleResults = new Map();
27
+ /** Set of changed POSIX ESM file paths pending bundling. */
28
+ pendingChangedEsmFiles = new Set();
29
+ /** Set of changed POSIX TypeScript declaration file paths pending bundling. */
30
+ pendingChangedDtsFiles = new Set();
31
+ /** Whether the previous build iteration encountered a compilation or diagnostic error. */
32
+ hasCompilationError = false;
33
+ /** Whether package.json and secondary entry point manifests have been emitted. */
34
+ hasEmittedManifests = false;
35
+ /** Whether the last emitted root package.json included a tslib dependency. */
36
+ hasEmittedTslib = false;
37
+ /** Whether static assets have been emitted in a prior iteration. */
38
+ hasEmittedAssets = false;
39
+ /** Whether entry points in package.json changed since the last compilation. */
40
+ hasEntryPointsChanges = false;
41
+ constructor(options) {
42
+ if (options?.tsConfigPath) {
43
+ this.#watchedCompilationFiles.add(options.tsConfigPath);
44
+ }
45
+ if (options?.packageJsonPath) {
46
+ this.#watchedCompilationFiles.add(options.packageJsonPath);
47
+ }
48
+ if (options?.entryPoints) {
49
+ for (const entryPoint of options.entryPoints.values()) {
50
+ this.#watchedCompilationFiles.add(entryPoint.entryFilePath);
51
+ }
52
+ }
53
+ }
54
+ /** Cached unified TypeScript and Angular compilation state. */
55
+ get singleProgramCache() {
56
+ return this.#singleProgramCache;
57
+ }
58
+ /** Effective compilation mode resolved from builder options and tsconfig. */
59
+ get compilationMode() {
60
+ return this.#compilationMode;
61
+ }
62
+ /** Whether any active entry point bundle imports `tslib`. */
63
+ get hasTslibImport() {
64
+ for (const result of this.previousBundleResults.values()) {
65
+ if (result.hasTslibImport) {
66
+ return true;
67
+ }
68
+ }
69
+ return false;
70
+ }
71
+ /**
72
+ * Set of POSIX file paths tracked for compilation and configuration
73
+ * (including `tsconfig.json`, `package.json`, entry points, and referenced source,
74
+ * template, and stylesheet files).
75
+ */
76
+ get watchedCompilationFiles() {
77
+ return this.#watchedCompilationFiles;
78
+ }
79
+ /**
80
+ * Execution result holding errors, warnings, and logs for the current build iteration.
81
+ */
82
+ get executionResult() {
83
+ return this.#executionResult;
84
+ }
85
+ /**
86
+ * Resets the execution result for a new build iteration.
87
+ *
88
+ * @returns The fresh `ExecutionResult` instance for the current build iteration.
89
+ */
90
+ resetExecutionResult() {
91
+ this.#executionResult = new execution_result_1.ExecutionResult();
92
+ return this.#executionResult;
93
+ }
94
+ /**
95
+ * Records transitive resource dependencies (such as Sass partials) for a containing
96
+ * component or stylesheet file and registers them in `watchedCompilationFiles`.
97
+ * Multiple calls for the same containing file accumulate references additively.
98
+ *
99
+ * @param containingFile Path of the referencing component or stylesheet file.
100
+ * @param referencedFiles Paths of the referenced files.
101
+ */
102
+ addFileReferences(containingFile, referencedFiles) {
103
+ const posixContainingFile = (0, path_1.toPosixPath)(containingFile);
104
+ let forwardReferences = this.#referencedByFile.get(posixContainingFile);
105
+ for (const file of referencedFiles) {
106
+ const posixFile = (0, path_1.toPosixPath)(file);
107
+ this.#watchedCompilationFiles.add(posixFile);
108
+ if (posixFile === posixContainingFile) {
109
+ continue;
110
+ }
111
+ if (!forwardReferences) {
112
+ forwardReferences = new Set();
113
+ this.#referencedByFile.set(posixContainingFile, forwardReferences);
114
+ }
115
+ forwardReferences.add(posixFile);
116
+ let referencing = this.#referencingFiles.get(posixFile);
117
+ if (!referencing) {
118
+ referencing = new Set();
119
+ this.#referencingFiles.set(posixFile, referencing);
120
+ }
121
+ referencing.add(posixContainingFile);
122
+ }
123
+ }
124
+ /**
125
+ * Clears previously recorded outgoing resource references for the given containing files
126
+ * before they are recompiled.
127
+ *
128
+ * @param containingFiles Paths of the containing or stylesheet files being recompiled.
129
+ */
130
+ clearFileReferences(containingFiles) {
131
+ for (const containingFile of containingFiles) {
132
+ const posixContainingFile = (0, path_1.toPosixPath)(containingFile);
133
+ const forwardReferences = this.#referencedByFile.get(posixContainingFile);
134
+ if (!forwardReferences) {
135
+ continue;
136
+ }
137
+ for (const prevRef of forwardReferences) {
138
+ const referencing = this.#referencingFiles.get(prevRef);
139
+ if (referencing) {
140
+ referencing.delete(posixContainingFile);
141
+ if (referencing.size === 0) {
142
+ this.#referencingFiles.delete(prevRef);
143
+ }
144
+ }
145
+ }
146
+ this.#referencedByFile.delete(posixContainingFile);
147
+ }
148
+ }
149
+ /**
150
+ * Returns the set of all files affected by the given changed files, including the
151
+ * changed files themselves and all transitively referencing files
152
+ * (e.g., partial `.scss` -> component `.scss` -> component `.ts`).
153
+ *
154
+ * @param files Initial changed file paths.
155
+ * @returns Set of POSIX paths including all transitively referencing files.
156
+ */
157
+ getAffectedFiles(files) {
158
+ const affected = new Set();
159
+ for (const file of files) {
160
+ affected.add((0, path_1.toPosixPath)(file));
161
+ }
162
+ for (const file of affected) {
163
+ const referencing = this.#referencingFiles.get(file);
164
+ if (referencing) {
165
+ for (const refFile of referencing) {
166
+ affected.add(refFile);
167
+ }
168
+ }
169
+ }
170
+ return affected;
171
+ }
172
+ /**
173
+ * Determines whether compilation and bundling need to run for the current build iteration.
174
+ * Also records incoming modified files so they are retained if the iteration aborts early.
175
+ *
176
+ * @param packageJsonPath Normalized POSIX path to the library's `package.json`.
177
+ * @param modifiedFiles Optional set of modified POSIX file paths in watch mode.
178
+ * @returns `true` if entry points should be compiled; otherwise `false`.
179
+ */
180
+ shouldCompileEntryPoints(packageJsonPath, modifiedFiles) {
181
+ if (modifiedFiles) {
182
+ for (const file of modifiedFiles) {
183
+ if (file !== packageJsonPath) {
184
+ this.#pendingCompilationFiles.add(file);
185
+ }
186
+ }
187
+ }
188
+ if (!modifiedFiles ||
189
+ !this.#singleProgramCache ||
190
+ this.hasCompilationError ||
191
+ this.hasEntryPointsChanges ||
192
+ this.pendingChangedEsmFiles.size > 0 ||
193
+ this.pendingChangedDtsFiles.size > 0) {
194
+ return true;
195
+ }
196
+ for (const file of this.#pendingCompilationFiles) {
197
+ if (this.#watchedCompilationFiles.has(file)) {
198
+ return true;
199
+ }
200
+ }
201
+ this.#pendingCompilationFiles.clear();
202
+ return false;
203
+ }
204
+ /**
205
+ * Returns the effective set of modified POSIX file paths for compilation,
206
+ * merging any pending compilation files from earlier aborted iterations.
207
+ *
208
+ * @param modifiedFiles Optional set of modified POSIX file paths from the current iteration.
209
+ * @returns Merged set of modified POSIX file paths, or `undefined` for a full compilation.
210
+ */
211
+ getCompilationModifiedFiles(modifiedFiles) {
212
+ if (!modifiedFiles) {
213
+ this.#pendingCompilationFiles.clear();
214
+ return undefined;
215
+ }
216
+ const files = new Set(modifiedFiles);
217
+ for (const file of this.#pendingCompilationFiles) {
218
+ files.add(file);
219
+ }
220
+ return files;
221
+ }
222
+ /**
223
+ * Records compilation output into the build state, updating the program cache,
224
+ * watched compilation files, and pending changed ESM/DTS file sets.
225
+ *
226
+ * @param output The compilation output produced by `compileLibrary`.
227
+ */
228
+ recordCompilationOutput(output) {
229
+ this.#pendingCompilationFiles.clear();
230
+ this.#singleProgramCache = output.cache;
231
+ if (this.#compilationMode !== output.compilationMode) {
232
+ this.#compilationMode = output.compilationMode;
233
+ this.hasEmittedManifests = false;
234
+ }
235
+ for (const file of output.referencedFiles) {
236
+ this.#watchedCompilationFiles.add(file);
237
+ }
238
+ for (const file of output.changedEsmFiles) {
239
+ this.pendingChangedEsmFiles.add(file);
240
+ }
241
+ for (const file of output.changedDtsFiles) {
242
+ this.pendingChangedDtsFiles.add(file);
243
+ }
244
+ }
245
+ /**
246
+ * Records active bundle results across entry points after compilation and bundling succeed,
247
+ * clearing pending compilation/bundle flags.
248
+ *
249
+ * @param bundleResults Newly bundled results keyed by entry point name.
250
+ */
251
+ recordBundleOutput(bundleResults) {
252
+ this.hasCompilationError = false;
253
+ this.hasEntryPointsChanges = false;
254
+ this.pendingChangedEsmFiles.clear();
255
+ this.pendingChangedDtsFiles.clear();
256
+ for (const [name, bundleResult] of bundleResults) {
257
+ this.previousBundleResults.set(name, bundleResult);
258
+ }
259
+ }
260
+ /**
261
+ * Disposes active compilation resources and clears cached state.
262
+ */
263
+ async dispose() {
264
+ await this.#singleProgramCache?.compilationInstance.close?.();
265
+ this.#singleProgramCache = undefined;
266
+ this.#compilationMode = undefined;
267
+ this.hasEmittedTslib = false;
268
+ this.hasEmittedAssets = false;
269
+ this.hasCompilationError = false;
270
+ this.hasEmittedManifests = false;
271
+ this.hasEntryPointsChanges = false;
272
+ this.previousBundleResults.clear();
273
+ this.pendingChangedEsmFiles.clear();
274
+ this.pendingChangedDtsFiles.clear();
275
+ this.#pendingCompilationFiles.clear();
276
+ this.#referencingFiles.clear();
277
+ this.#referencedByFile.clear();
278
+ this.#watchedCompilationFiles.clear();
279
+ }
280
+ }
281
+ exports.BuilderState = BuilderState;
282
+ //# sourceMappingURL=builder-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder-state.js","sourceRoot":"","sources":["builder-state.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,2CAA+C;AAC/C,yDAAqD;AAQrD;;;GAGG;AACH,MAAa,YAAY;IACd,iBAAiB,GAAG,IAAI,GAAG,EAAuB,CAAC;IACnD,iBAAiB,GAAG,IAAI,GAAG,EAAuB,CAAC;IACnD,wBAAwB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC7C,wBAAwB,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtD,gBAAgB,GAAG,IAAI,kCAAe,EAAE,CAAC;IACzC,mBAAmB,CAAsB;IACzC,gBAAgB,CAAsB;IAEtC,iEAAiE;IACxD,qBAAqB,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEjE,4DAA4D;IACnD,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAC;IAEpD,+EAA+E;IACtE,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAC;IAEpD,0FAA0F;IAC1F,mBAAmB,GAAG,KAAK,CAAC;IAE5B,kFAAkF;IAClF,mBAAmB,GAAG,KAAK,CAAC;IAE5B,8EAA8E;IAC9E,eAAe,GAAG,KAAK,CAAC;IAExB,oEAAoE;IACpE,gBAAgB,GAAG,KAAK,CAAC;IAEzB,+EAA+E;IAC/E,qBAAqB,GAAG,KAAK,CAAC;IAE9B,YACE,OAEC;QAED,IAAI,OAAO,EAAE,YAAY,EAAE,CAAC;YAC1B,IAAI,CAAC,wBAAwB,CAAC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;QACjC,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAC;QACnC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAAC;QACpC,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAAC;QACpC,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;QACtC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;IACxC,CAAC;CACF;AAvTD,oCAuTC"}
@@ -39,12 +39,8 @@ var __importStar = (this && this.__importStar) || (function () {
39
39
  return result;
40
40
  };
41
41
  })();
42
- var __importDefault = (this && this.__importDefault) || function (mod) {
43
- return (mod && mod.__esModule) ? mod : { "default": mod };
44
- };
45
42
  Object.defineProperty(exports, "__esModule", { value: true });
46
43
  exports.executeLibraryBuilder = executeLibraryBuilder;
47
- const promises_1 = __importDefault(require("node:fs/promises"));
48
44
  const sass_language_1 = require("../../tools/esbuild/stylesheets/sass-language");
49
45
  const target_1 = require("../../tools/esbuild/target");
50
46
  const utils_1 = require("../../tools/esbuild/utils");
@@ -56,8 +52,10 @@ const profiling_1 = require("../../utils/profiling");
56
52
  const purge_cache_1 = require("../../utils/purge-cache");
57
53
  const supported_browsers_1 = require("../../utils/supported-browsers");
58
54
  const version_1 = require("../../utils/version");
55
+ const builder_state_1 = require("./builder-state");
59
56
  const options_1 = require("./options");
60
57
  const entry_points_1 = require("./pipeline/entry-points");
58
+ const utils_2 = require("./pipeline/utils");
61
59
  /**
62
60
  * Executes the library builder to compile, bundle, and package an Angular library into the Angular Package Format (APF).
63
61
  *
@@ -67,16 +65,18 @@ const entry_points_1 = require("./pipeline/entry-points");
67
65
  */
68
66
  async function* executeLibraryBuilder(options, context) {
69
67
  (0, version_1.assertCompatibleAngularVersion)(context.workspaceRoot);
70
- await (0, hash_1.initializeHash)();
71
- // Purge old build disk cache
72
- await (0, purge_cache_1.purgeStaleBuildCache)(context);
73
68
  const projectName = context.target?.project;
74
69
  if (!projectName) {
75
70
  yield { success: false, error: 'The library builder requires a target.' };
76
71
  return;
77
72
  }
78
- const normalizedOptions = await (0, options_1.normalizeLibraryOptions)(context, projectName, options);
79
- const { workspaceRoot, projectRoot, outputPath, deleteOutputPath, packageJsonPath, tsConfigPath, watch: isWatchMode, poll, cacheOptions, preserveSymlinks, progress, } = normalizedOptions;
73
+ const [normalizedOptions] = await Promise.all([
74
+ (0, options_1.normalizeLibraryOptions)(context, projectName, options),
75
+ (0, hash_1.initializeHash)(),
76
+ // Purge old build disk cache
77
+ (0, purge_cache_1.purgeStaleBuildCache)(context),
78
+ ]);
79
+ const { workspaceRoot, projectRoot, outputPath, deleteOutputPath, watch: isWatchMode, poll, cacheOptions, preserveSymlinks, progress, } = normalizedOptions;
80
80
  let signal = context.signal;
81
81
  if (!signal) {
82
82
  const controller = new AbortController();
@@ -90,29 +90,18 @@ async function* executeLibraryBuilder(options, context) {
90
90
  await (0, delete_output_dir_1.deleteOutputDir)(workspaceRoot, outputPath);
91
91
  }
92
92
  // Dynamically lazy-loaded to prevent importing dependencies at the top level.
93
- const [{ buildAction, createSingleBuildState, hasModifiedWatchedFile }, { createComponentStylesheetBundlerForLibrary },] = await Promise.all([
93
+ const [{ buildAction }, { createComponentStylesheetBundlerForLibrary }] = await Promise.all([
94
94
  Promise.resolve().then(() => __importStar(require('./pipeline/build-action'))),
95
95
  Promise.resolve().then(() => __importStar(require('./pipeline/stylesheet-bundler'))),
96
96
  ]);
97
97
  let stylesheetBundler;
98
98
  let watcher;
99
- const buildState = createSingleBuildState();
99
+ const buildState = new builder_state_1.BuilderState(normalizedOptions);
100
100
  try {
101
101
  const browsers = (0, supported_browsers_1.getSupportedBrowsers)(projectRoot, logger);
102
102
  const target = (0, target_1.transformSupportedBrowsersToTargets)(browsers);
103
103
  stylesheetBundler = createComponentStylesheetBundlerForLibrary(normalizedOptions, isWatchMode, target);
104
- // Track all referenced compilation files for watch mode
105
- const watchedCompilationFiles = new Set([
106
- (0, path_1.toPosixPath)(tsConfigPath),
107
- (0, path_1.toPosixPath)(packageJsonPath),
108
- ]);
109
- for (const entryPoint of normalizedOptions.entryPoints.values()) {
110
- watchedCompilationFiles.add((0, path_1.toPosixPath)(entryPoint.entryFilePath));
111
- }
112
104
  if (isWatchMode) {
113
- if (progress) {
114
- logger.info('Watch mode enabled. Watching for file changes...');
115
- }
116
105
  const { setupWatcher } = await Promise.resolve().then(() => __importStar(require('../../utils/watcher')));
117
106
  watcher = await setupWatcher({
118
107
  workspaceRoot,
@@ -122,7 +111,10 @@ async function* executeLibraryBuilder(options, context) {
122
111
  poll,
123
112
  preserveSymlinks,
124
113
  signal,
125
- watchFiles: watchedCompilationFiles,
114
+ watchFiles: [
115
+ ...buildState.watchedCompilationFiles,
116
+ ...normalizedOptions.assets.map((asset) => asset.input),
117
+ ],
126
118
  });
127
119
  context.addTeardown?.(() => void watcher?.close());
128
120
  }
@@ -130,16 +122,17 @@ async function* executeLibraryBuilder(options, context) {
130
122
  const initialResult = await executeBuild('Building...', {
131
123
  options: normalizedOptions,
132
124
  stylesheetBundler,
133
- watchedCompilationFiles,
134
125
  isWatchMode,
135
- context,
136
126
  buildState,
137
- }, withProgress, watcher, buildAction);
127
+ }, logger, withProgress, watcher, buildAction);
128
+ if (isWatchMode && progress) {
129
+ logger.info('Watch mode enabled. Watching for file changes...');
130
+ }
138
131
  yield initialResult;
139
132
  if (!isWatchMode || !watcher) {
140
133
  return;
141
134
  }
142
- yield* runWatchLoop(watcher, normalizedOptions, stylesheetBundler, watchedCompilationFiles, context, withProgress, buildState, buildAction, hasModifiedWatchedFile, signal);
135
+ yield* runWatchLoop(watcher, normalizedOptions, stylesheetBundler, logger, withProgress, buildState, buildAction, signal);
143
136
  }
144
137
  finally {
145
138
  (0, profiling_1.logCumulativeDurations)();
@@ -147,29 +140,43 @@ async function* executeLibraryBuilder(options, context) {
147
140
  await Promise.allSettled([
148
141
  watcher?.close(),
149
142
  stylesheetBundler?.dispose(),
150
- buildState.singleProgramCache?.compilationInstance.close?.(),
143
+ buildState.dispose(),
151
144
  ]);
152
145
  }
153
146
  }
154
- async function executeBuild(message, actionContext, withProgress, watcher, buildAction) {
147
+ /**
148
+ * Executes a single build iteration with progress reporting, logs any resulting
149
+ * messages, and registers newly discovered files with the watcher.
150
+ *
151
+ * @param message Progress spinner message to display while building.
152
+ * @param actionContext The build action context and state.
153
+ * @param logger The Architect logger API.
154
+ * @param withProgress Progress wrapper function (`withSpinner` or `withNoProgress`).
155
+ * @param watcher Optional file watcher for watch mode.
156
+ * @param buildAction The library build action function to execute.
157
+ * @returns A promise resolving to the Architect `BuilderOutput`.
158
+ */
159
+ async function executeBuild(message, actionContext, logger, withProgress, watcher, buildAction) {
155
160
  const startTime = process.hrtime.bigint();
156
- const { context, watchedCompilationFiles, isWatchMode } = actionContext;
161
+ const { buildState, isWatchMode, options } = actionContext;
157
162
  try {
158
- await withProgress(message, () => buildAction(actionContext));
159
- logBuildResult(context.logger, startTime, true);
160
- if (isWatchMode) {
163
+ const result = await withProgress(message, () => buildAction(actionContext));
164
+ logMessages(logger, result);
165
+ const { output } = result;
166
+ logBuildResult(logger, startTime, output.success, options.outputPath);
167
+ if (output.success && isWatchMode) {
161
168
  (0, profiling_1.logCumulativeDurations)();
162
169
  }
163
- return { success: true };
170
+ return output;
164
171
  }
165
172
  catch (error) {
166
173
  (0, error_1.assertIsError)(error);
167
- logBuildResult(context.logger, startTime, false);
174
+ logBuildResult(logger, startTime, false);
168
175
  return { success: false, error: error.message };
169
176
  }
170
177
  finally {
171
178
  if (watcher) {
172
- watcher.add(Array.from(watchedCompilationFiles));
179
+ watcher.add(Array.from(buildState.watchedCompilationFiles));
173
180
  const { assetsToEmit } = actionContext;
174
181
  if (assetsToEmit?.length) {
175
182
  watcher.add(assetsToEmit.map((asset) => asset.source));
@@ -179,61 +186,50 @@ async function executeBuild(message, actionContext, withProgress, watcher, build
179
186
  }
180
187
  /**
181
188
  * Runs the watch loop, rebuilding the library as watched files are modified.
189
+ *
190
+ * @param watcher The file watcher instance.
191
+ * @param options The normalized library builder options with POSIX paths.
192
+ * @param stylesheetBundler The component stylesheet bundler instance.
193
+ * @param logger The Architect logger API.
194
+ * @param withProgress Progress wrapper function (`withSpinner` or `withNoProgress`).
195
+ * @param buildState The state preserved across incremental builds.
196
+ * @param buildAction The library build action function to execute.
197
+ * @param signal Abort signal to terminate the watch loop.
198
+ * @returns An async iterator yielding builder output results.
182
199
  */
183
- async function* runWatchLoop(watcher, options, stylesheetBundler, watchedCompilationFiles, context, withProgress, buildState, buildAction, hasModifiedWatchedFile, signal) {
200
+ async function* runWatchLoop(watcher, options, stylesheetBundler, logger, withProgress, buildState, buildAction, signal) {
184
201
  const { collectAssetsToEmit } = await Promise.resolve().then(() => __importStar(require('./pipeline/assets')));
185
202
  const { workspaceRoot, packageJsonPath, assets, clearScreen } = options;
186
- const posixPackageJsonPath = (0, path_1.toPosixPath)(packageJsonPath);
187
203
  for await (const changes of watcher) {
188
- if (signal?.aborted) {
204
+ if (signal.aborted) {
189
205
  break;
190
206
  }
191
207
  if (clearScreen) {
192
208
  // eslint-disable-next-line no-console
193
209
  console.clear();
194
210
  }
195
- const changedFiles = new Set();
196
- let hasStyleChanges = false;
197
- let hasSassChanges = false;
198
- for (const file of changes.all) {
199
- const posixFile = (0, path_1.toPosixPath)(file);
200
- changedFiles.add(posixFile);
211
+ const rawChangedFiles = changes.all.map(path_1.toPosixPath);
212
+ stylesheetBundler.invalidate(rawChangedFiles);
213
+ const changedFiles = buildState.getAffectedFiles(rawChangedFiles);
214
+ for (const posixFile of changedFiles) {
201
215
  if (/\.(?:scss|sass)$/i.test(posixFile)) {
202
- hasStyleChanges = true;
203
- hasSassChanges = true;
204
- }
205
- else if (/\.(?:less|css)$/i.test(posixFile)) {
206
- hasStyleChanges = true;
207
- }
208
- }
209
- if (hasStyleChanges) {
210
- if (hasSassChanges) {
211
216
  (0, sass_language_1.resetSassWorkerPoolCaches)();
212
- }
213
- const invalidatedStyles = stylesheetBundler.invalidate(changedFiles);
214
- if (invalidatedStyles) {
215
- for (const styleFile of invalidatedStyles) {
216
- changedFiles.add((0, path_1.toPosixPath)(styleFile));
217
- }
217
+ break;
218
218
  }
219
219
  }
220
220
  // Check if package.json was modified
221
- let hasPackageJsonChanges = false;
222
- if (changedFiles.has(posixPackageJsonPath)) {
221
+ if (changedFiles.has(packageJsonPath)) {
222
+ buildState.hasEmittedManifests = false;
223
223
  try {
224
- const packageJson = await loadPackageJson(packageJsonPath);
225
- options.packageJson = packageJson;
226
- if (!packageJson.name) {
227
- throw new Error(`The package.json at '${packageJsonPath}' must contain a 'name'.`);
228
- }
229
- options.packageName = packageJson.name;
230
- (0, entry_points_1.updateWatchedEntryPoints)(packageJson, options, buildState, watchedCompilationFiles, packageJsonPath);
231
- hasPackageJsonChanges = true;
224
+ const packageJson = await (0, utils_2.loadPackageJson)(packageJsonPath);
225
+ (0, entry_points_1.updateWatchedEntryPoints)(packageJson, options, buildState);
232
226
  }
233
227
  catch (error) {
234
228
  (0, error_1.assertIsError)(error);
235
229
  await buildState.singleProgramCache?.compilationInstance.update?.(changedFiles);
236
- buildState.hasEmittedManifests = false;
230
+ if (buildState.shouldCompileEntryPoints(packageJsonPath, changedFiles)) {
231
+ buildState.hasCompilationError = true;
232
+ }
237
233
  yield {
238
234
  success: false,
239
235
  error: `Failed to reload 'package.json': ${error.message}`,
@@ -241,45 +237,61 @@ async function* runWatchLoop(watcher, options, stylesheetBundler, watchedCompila
241
237
  continue;
242
238
  }
243
239
  }
244
- const hasSourceChanges = !buildState.singleProgramCache ||
245
- buildState.hasCompilationError ||
246
- buildState.hasEntryPointsChanges ||
247
- hasModifiedWatchedFile(changedFiles, watchedCompilationFiles, posixPackageJsonPath);
240
+ const hasSourceChanges = buildState.shouldCompileEntryPoints(packageJsonPath, changedFiles);
241
+ if (!hasSourceChanges) {
242
+ await buildState.singleProgramCache?.compilationInstance.update?.(changedFiles);
243
+ }
248
244
  const assetsToEmit = await collectAssetsToEmit(assets, workspaceRoot, buildState.hasEmittedAssets ? changedFiles : undefined);
249
- if (!hasSourceChanges && !hasPackageJsonChanges && assetsToEmit.length === 0) {
245
+ if (!hasSourceChanges && buildState.hasEmittedManifests && assetsToEmit.length === 0) {
250
246
  continue;
251
247
  }
252
248
  yield await executeBuild('Changes detected. Rebuilding...', {
253
249
  options,
254
250
  stylesheetBundler,
255
- watchedCompilationFiles,
256
251
  isWatchMode: true,
257
- context,
258
252
  buildState,
259
253
  modifiedFiles: changedFiles,
260
254
  assetsToEmit,
261
- }, withProgress, watcher, buildAction);
255
+ }, logger, withProgress, watcher, buildAction);
262
256
  }
263
257
  }
264
258
  /**
265
- * Loads and parses a JSON file from disk.
259
+ * Logs informational, warning, and error messages produced during a build iteration.
260
+ *
261
+ * @param logger The Architect logger API.
262
+ * @param result The build execution result containing logs, warnings, and errors.
266
263
  */
267
- async function loadPackageJson(packageJsonPath) {
268
- const content = await promises_1.default.readFile(packageJsonPath, 'utf-8');
269
- return JSON.parse(content);
264
+ function logMessages(logger, { logs, warnings, errors }) {
265
+ if (logs.length) {
266
+ logger.info(logs.join('\n'));
267
+ }
268
+ if (warnings.length) {
269
+ logger.warn(warnings.join('\n'));
270
+ }
271
+ if (errors.length) {
272
+ logger.error(errors.join('\n'));
273
+ }
270
274
  }
271
275
  /**
272
276
  * Logs the build completion time and status.
277
+ *
278
+ * @param logger The Architect logger API.
279
+ * @param startTime High-resolution timestamp recorded when the build iteration started.
280
+ * @param success Whether the build iteration succeeded without errors.
281
+ * @param outputPath Optional POSIX output directory path to log on successful builds.
273
282
  */
274
- function logBuildResult(logger, startTime, success) {
275
- const durationMs = Number(process.hrtime.bigint() - startTime) / 1_000_000;
276
- const durationSec = (durationMs / 1000).toFixed(2);
283
+ function logBuildResult(logger, startTime, success, outputPath) {
284
+ const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
285
+ const message = `Library bundle generation ${success ? 'complete' : 'failed'}.` +
286
+ ` [${buildTime.toFixed(3)} seconds] - ${new Date().toISOString()}`;
277
287
  if (success) {
278
- logger.info(`Build at: ${new Date().toISOString()} - Time: ${durationMs.toFixed(0)}ms`);
279
- logger.info(`Built Angular library in ${durationSec}s.`);
288
+ logger.info(message);
289
+ if (outputPath) {
290
+ logger.info(`Output location: ${outputPath}\n`);
291
+ }
280
292
  }
281
293
  else {
282
- logger.error(`Build failed after ${durationSec}s.`);
294
+ logger.error(message);
283
295
  }
284
296
  }
285
297
  //# sourceMappingURL=builder.js.map