@angular/build 22.3.0-next.0 → 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 (141) 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/chunk-optimizer.js +2 -1
  5. package/src/builders/application/chunk-optimizer.js.map +1 -1
  6. package/src/builders/application/index.js +8 -31
  7. package/src/builders/application/index.js.map +1 -1
  8. package/src/builders/application/options.d.ts +1 -3
  9. package/src/builders/application/options.js +2 -3
  10. package/src/builders/application/options.js.map +1 -1
  11. package/src/builders/application/results.d.ts +1 -1
  12. package/src/builders/dev-server/options.js +1 -1
  13. package/src/builders/dev-server/options.js.map +1 -1
  14. package/src/builders/dev-server/vite/server.js +1 -1
  15. package/src/builders/dev-server/vite/server.js.map +1 -1
  16. package/src/builders/dev-server/vite/utils.js +1 -1
  17. package/src/builders/dev-server/vite/utils.js.map +1 -1
  18. package/src/builders/extract-i18n/application-extraction.js +2 -1
  19. package/src/builders/extract-i18n/application-extraction.js.map +1 -1
  20. package/src/builders/karma/assets-middleware.js +1 -1
  21. package/src/builders/karma/assets-middleware.js.map +1 -1
  22. package/src/builders/library/builder-state.d.ts +115 -0
  23. package/src/builders/library/builder-state.js +282 -0
  24. package/src/builders/library/builder-state.js.map +1 -0
  25. package/src/builders/library/builder.js +110 -92
  26. package/src/builders/library/builder.js.map +1 -1
  27. package/src/builders/library/execution-result.d.ts +35 -0
  28. package/src/builders/library/execution-result.js +67 -0
  29. package/src/builders/library/execution-result.js.map +1 -0
  30. package/src/builders/library/index.d.ts +1 -1
  31. package/src/builders/library/index.js.map +1 -1
  32. package/src/builders/library/options.d.ts +9 -0
  33. package/src/builders/library/options.js +29 -23
  34. package/src/builders/library/options.js.map +1 -1
  35. package/src/builders/library/pipeline/assets.d.ts +5 -16
  36. package/src/builders/library/pipeline/assets.js +16 -59
  37. package/src/builders/library/pipeline/assets.js.map +1 -1
  38. package/src/builders/library/pipeline/build-action.d.ts +21 -13
  39. package/src/builders/library/pipeline/build-action.js +76 -124
  40. package/src/builders/library/pipeline/build-action.js.map +1 -1
  41. package/src/builders/library/pipeline/bundler.d.ts +5 -3
  42. package/src/builders/library/pipeline/bundler.js +123 -43
  43. package/src/builders/library/pipeline/bundler.js.map +1 -1
  44. package/src/builders/library/pipeline/compilation.d.ts +7 -26
  45. package/src/builders/library/pipeline/compilation.js +59 -69
  46. package/src/builders/library/pipeline/compilation.js.map +1 -1
  47. package/src/builders/library/pipeline/entry-points.d.ts +26 -6
  48. package/src/builders/library/pipeline/entry-points.js +82 -21
  49. package/src/builders/library/pipeline/entry-points.js.map +1 -1
  50. package/src/builders/library/pipeline/package-manifests.d.ts +2 -1
  51. package/src/builders/library/pipeline/package-manifests.js +50 -1
  52. package/src/builders/library/pipeline/package-manifests.js.map +1 -1
  53. package/src/builders/library/pipeline/stylesheet-bundler.d.ts +4 -1
  54. package/src/builders/library/pipeline/stylesheet-bundler.js +1 -1
  55. package/src/builders/library/pipeline/stylesheet-bundler.js.map +1 -1
  56. package/src/builders/library/pipeline/utils.d.ts +19 -11
  57. package/src/builders/library/pipeline/utils.js +27 -11
  58. package/src/builders/library/pipeline/utils.js.map +1 -1
  59. package/src/builders/library/schema.json +2 -4
  60. package/src/builders/library/types.d.ts +62 -22
  61. package/src/builders/ng-packagr/builder.js +2 -2
  62. package/src/builders/ng-packagr/builder.js.map +1 -1
  63. package/src/builders/unit-test/builder.js +1 -1
  64. package/src/builders/unit-test/builder.js.map +1 -1
  65. package/src/builders/unit-test/options.js +1 -2
  66. package/src/builders/unit-test/options.js.map +1 -1
  67. package/src/builders/unit-test/runners/vitest/executor.js +0 -5
  68. package/src/builders/unit-test/runners/vitest/executor.js.map +1 -1
  69. package/src/builders/unit-test/runners/vitest/plugins.js +13 -1
  70. package/src/builders/unit-test/runners/vitest/plugins.js.map +1 -1
  71. package/src/builders/unit-test/test-discovery.js +4 -2
  72. package/src/builders/unit-test/test-discovery.js.map +1 -1
  73. package/src/private.d.ts +1 -1
  74. package/src/private.js +3 -3
  75. package/src/private.js.map +1 -1
  76. package/src/tools/angular/angular-host.d.ts +1 -1
  77. package/src/tools/angular/angular-host.js +5 -2
  78. package/src/tools/angular/angular-host.js.map +1 -1
  79. package/src/tools/angular/compilation/angular-compilation.d.ts +1 -0
  80. package/src/tools/angular/compilation/angular-compilation.js.map +1 -1
  81. package/src/tools/angular/compilation/aot-compilation.js +325 -80
  82. package/src/tools/angular/compilation/aot-compilation.js.map +1 -1
  83. package/src/tools/angular/compilation/compiler-options.js +4 -1
  84. package/src/tools/angular/compilation/compiler-options.js.map +1 -1
  85. package/src/tools/angular/compilation/jit-compilation.js +5 -4
  86. package/src/tools/angular/compilation/jit-compilation.js.map +1 -1
  87. package/src/tools/angular/compilation/parallel-worker.js +1 -0
  88. package/src/tools/angular/compilation/parallel-worker.js.map +1 -1
  89. package/src/tools/angular/compilation/typescript-compilation.d.ts +2 -0
  90. package/src/tools/angular/compilation/typescript-compilation.js +44 -5
  91. package/src/tools/angular/compilation/typescript-compilation.js.map +1 -1
  92. package/src/tools/esbuild/bundler-context.js +5 -1
  93. package/src/tools/esbuild/bundler-context.js.map +1 -1
  94. package/src/tools/esbuild/persistent-load-result-cache.js +2 -4
  95. package/src/tools/esbuild/persistent-load-result-cache.js.map +1 -1
  96. package/src/tools/esbuild/utils.d.ts +1 -2
  97. package/src/tools/esbuild/utils.js +0 -13
  98. package/src/tools/esbuild/utils.js.map +1 -1
  99. package/src/tools/sass/rebasing-importer.d.ts +1 -1
  100. package/src/tools/sass/rebasing-importer.js +6 -3
  101. package/src/tools/sass/rebasing-importer.js.map +1 -1
  102. package/src/tools/vite/middlewares/assets-middleware.js +1 -1
  103. package/src/tools/vite/middlewares/assets-middleware.js.map +1 -1
  104. package/src/utils/concurrency.d.ts +4 -0
  105. package/src/utils/concurrency.js +5 -0
  106. package/src/utils/concurrency.js.map +1 -1
  107. package/src/utils/delete-output-dir.js +3 -2
  108. package/src/utils/delete-output-dir.js.map +1 -1
  109. package/src/utils/disk-files.d.ts +30 -0
  110. package/src/utils/disk-files.js +68 -0
  111. package/src/utils/disk-files.js.map +1 -0
  112. package/src/utils/index-file/nonce.d.ts +2 -1
  113. package/src/utils/index-file/nonce.js +22 -4
  114. package/src/utils/index-file/nonce.js.map +1 -1
  115. package/src/utils/load-proxy-config.js +12 -10
  116. package/src/utils/load-proxy-config.js.map +1 -1
  117. package/src/utils/load-rolldown.d.ts +27 -0
  118. package/src/utils/load-rolldown.js +79 -0
  119. package/src/utils/load-rolldown.js.map +1 -0
  120. package/src/utils/normalize-asset-patterns.d.ts +18 -3
  121. package/src/utils/normalize-asset-patterns.js +34 -67
  122. package/src/utils/normalize-asset-patterns.js.map +1 -1
  123. package/src/utils/normalize-cache.d.ts +14 -1
  124. package/src/utils/normalize-cache.js +18 -4
  125. package/src/utils/normalize-cache.js.map +1 -1
  126. package/src/utils/postcss-configuration.d.ts +2 -2
  127. package/src/utils/postcss-configuration.js +3 -3
  128. package/src/utils/postcss-configuration.js.map +1 -1
  129. package/src/utils/resolve-assets.js +28 -9
  130. package/src/utils/resolve-assets.js.map +1 -1
  131. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +1 -1
  132. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +3 -3
  133. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js.map +1 -1
  134. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +3 -2
  135. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js.map +1 -1
  136. package/src/utils/test-files.js +5 -57
  137. package/src/utils/test-files.js.map +1 -1
  138. package/src/utils/watcher.d.ts +53 -0
  139. package/src/utils/watcher.js +404 -76
  140. package/src/utils/watcher.js.map +1 -1
  141. package/src/builders/library/pipeline/types.d.ts +0 -54
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { ExecutionResult } from './execution-result';
9
+ import type { BundleResult, LibraryCompilationOutput, NormalizedLibraryOptions, SingleProgramCache } from './types';
10
+ /**
11
+ * Encapsulates incremental compilation state, transitive resource reference tracking,
12
+ * watched compilation file tracking, and execution results across watch-mode rebuilds.
13
+ */
14
+ export declare class BuilderState {
15
+ #private;
16
+ /** Map of entry point names to their previous bundle results. */
17
+ readonly previousBundleResults: Map<string, BundleResult>;
18
+ /** Set of changed POSIX ESM file paths pending bundling. */
19
+ readonly pendingChangedEsmFiles: Set<string>;
20
+ /** Set of changed POSIX TypeScript declaration file paths pending bundling. */
21
+ readonly pendingChangedDtsFiles: Set<string>;
22
+ /** Whether the previous build iteration encountered a compilation or diagnostic error. */
23
+ hasCompilationError: boolean;
24
+ /** Whether package.json and secondary entry point manifests have been emitted. */
25
+ hasEmittedManifests: boolean;
26
+ /** Whether the last emitted root package.json included a tslib dependency. */
27
+ hasEmittedTslib: boolean;
28
+ /** Whether static assets have been emitted in a prior iteration. */
29
+ hasEmittedAssets: boolean;
30
+ /** Whether entry points in package.json changed since the last compilation. */
31
+ hasEntryPointsChanges: boolean;
32
+ constructor(options?: Partial<Pick<NormalizedLibraryOptions, 'tsConfigPath' | 'packageJsonPath' | 'entryPoints'>>);
33
+ /** Cached unified TypeScript and Angular compilation state. */
34
+ get singleProgramCache(): SingleProgramCache | undefined;
35
+ /** Effective compilation mode resolved from builder options and tsconfig. */
36
+ get compilationMode(): 'partial' | 'full' | undefined;
37
+ /** Whether any active entry point bundle imports `tslib`. */
38
+ get hasTslibImport(): boolean;
39
+ /**
40
+ * Set of POSIX file paths tracked for compilation and configuration
41
+ * (including `tsconfig.json`, `package.json`, entry points, and referenced source,
42
+ * template, and stylesheet files).
43
+ */
44
+ get watchedCompilationFiles(): Set<string>;
45
+ /**
46
+ * Execution result holding errors, warnings, and logs for the current build iteration.
47
+ */
48
+ get executionResult(): ExecutionResult;
49
+ /**
50
+ * Resets the execution result for a new build iteration.
51
+ *
52
+ * @returns The fresh `ExecutionResult` instance for the current build iteration.
53
+ */
54
+ resetExecutionResult(): ExecutionResult;
55
+ /**
56
+ * Records transitive resource dependencies (such as Sass partials) for a containing
57
+ * component or stylesheet file and registers them in `watchedCompilationFiles`.
58
+ * Multiple calls for the same containing file accumulate references additively.
59
+ *
60
+ * @param containingFile Path of the referencing component or stylesheet file.
61
+ * @param referencedFiles Paths of the referenced files.
62
+ */
63
+ addFileReferences(containingFile: string, referencedFiles: Iterable<string>): void;
64
+ /**
65
+ * Clears previously recorded outgoing resource references for the given containing files
66
+ * before they are recompiled.
67
+ *
68
+ * @param containingFiles Paths of the containing or stylesheet files being recompiled.
69
+ */
70
+ clearFileReferences(containingFiles: Iterable<string>): void;
71
+ /**
72
+ * Returns the set of all files affected by the given changed files, including the
73
+ * changed files themselves and all transitively referencing files
74
+ * (e.g., partial `.scss` -> component `.scss` -> component `.ts`).
75
+ *
76
+ * @param files Initial changed file paths.
77
+ * @returns Set of POSIX paths including all transitively referencing files.
78
+ */
79
+ getAffectedFiles(files: Iterable<string>): Set<string>;
80
+ /**
81
+ * Determines whether compilation and bundling need to run for the current build iteration.
82
+ * Also records incoming modified files so they are retained if the iteration aborts early.
83
+ *
84
+ * @param packageJsonPath Normalized POSIX path to the library's `package.json`.
85
+ * @param modifiedFiles Optional set of modified POSIX file paths in watch mode.
86
+ * @returns `true` if entry points should be compiled; otherwise `false`.
87
+ */
88
+ shouldCompileEntryPoints(packageJsonPath: string, modifiedFiles?: ReadonlySet<string>): boolean;
89
+ /**
90
+ * Returns the effective set of modified POSIX file paths for compilation,
91
+ * merging any pending compilation files from earlier aborted iterations.
92
+ *
93
+ * @param modifiedFiles Optional set of modified POSIX file paths from the current iteration.
94
+ * @returns Merged set of modified POSIX file paths, or `undefined` for a full compilation.
95
+ */
96
+ getCompilationModifiedFiles(modifiedFiles?: ReadonlySet<string>): Set<string> | undefined;
97
+ /**
98
+ * Records compilation output into the build state, updating the program cache,
99
+ * watched compilation files, and pending changed ESM/DTS file sets.
100
+ *
101
+ * @param output The compilation output produced by `compileLibrary`.
102
+ */
103
+ recordCompilationOutput(output: LibraryCompilationOutput): void;
104
+ /**
105
+ * Records active bundle results across entry points after compilation and bundling succeed,
106
+ * clearing pending compilation/bundle flags.
107
+ *
108
+ * @param bundleResults Newly bundled results keyed by entry point name.
109
+ */
110
+ recordBundleOutput(bundleResults: ReadonlyMap<string, BundleResult>): void;
111
+ /**
112
+ * Disposes active compilation resources and clears cached state.
113
+ */
114
+ dispose(): Promise<void>;
115
+ }
@@ -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,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,OAAO,EAAE,eAAe,EAAE,CAAC;YAC7B,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAC7D,CAAC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