@angular-devkit/build-angular 18.0.0-next.3 → 18.0.0-next.5

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 (252) hide show
  1. package/builders.json +1 -5
  2. package/package.json +14 -13
  3. package/src/builders/app-shell/index.js +3 -5
  4. package/src/builders/browser/index.d.ts +1 -1
  5. package/src/builders/browser/index.js +8 -12
  6. package/src/builders/browser-esbuild/index.d.ts +2 -2
  7. package/src/builders/browser-esbuild/index.js +6 -9
  8. package/src/builders/dev-server/builder.d.ts +2 -2
  9. package/src/builders/dev-server/builder.js +11 -6
  10. package/src/builders/dev-server/index.d.ts +1 -1
  11. package/src/builders/dev-server/webpack-server.d.ts +1 -1
  12. package/src/builders/dev-server/webpack-server.js +3 -4
  13. package/src/builders/extract-i18n/application-extraction.js +2 -2
  14. package/src/builders/extract-i18n/builder.js +3 -4
  15. package/src/builders/extract-i18n/options.d.ts +1 -1
  16. package/src/builders/extract-i18n/options.js +2 -2
  17. package/src/builders/jest/index.js +2 -2
  18. package/src/builders/karma/index.js +3 -4
  19. package/src/builders/ng-packagr/index.js +8 -7
  20. package/src/builders/ng-packagr/schema.d.ts +4 -0
  21. package/src/builders/ng-packagr/schema.json +4 -0
  22. package/src/builders/prerender/index.js +2 -2
  23. package/src/builders/prerender/render-worker.js +1 -1
  24. package/src/builders/server/index.js +3 -4
  25. package/src/builders/server/platform-server-exports-loader.js +2 -1
  26. package/src/builders/ssr-dev-server/index.js +7 -7
  27. package/src/builders/web-test-runner/index.js +2 -2
  28. package/src/index.d.ts +1 -1
  29. package/src/index.js +2 -2
  30. package/src/tools/babel/presets/application.js +1 -1
  31. package/src/tools/webpack/configs/styles.js +2 -2
  32. package/src/tools/webpack/plugins/any-component-style-budget-checker.d.ts +1 -1
  33. package/src/tools/webpack/plugins/any-component-style-budget-checker.js +5 -5
  34. package/src/tools/webpack/plugins/css-optimizer-plugin.js +2 -2
  35. package/src/tools/webpack/plugins/index-html-webpack-plugin.d.ts +1 -1
  36. package/src/tools/webpack/plugins/index-html-webpack-plugin.js +2 -2
  37. package/src/tools/webpack/plugins/javascript-optimizer-plugin.js +2 -2
  38. package/src/tools/webpack/plugins/service-worker-plugin.js +2 -2
  39. package/src/tools/webpack/utils/stats.d.ts +1 -1
  40. package/src/tools/webpack/utils/stats.js +2 -2
  41. package/src/utils/i18n-webpack.d.ts +1 -1
  42. package/src/utils/i18n-webpack.js +5 -6
  43. package/src/utils/index.d.ts +1 -2
  44. package/src/utils/index.js +4 -2
  45. package/src/utils/normalize-builder-schema.js +2 -2
  46. package/src/utils/normalize-cache.js +1 -1
  47. package/src/utils/normalize-optimization.d.ts +1 -1
  48. package/src/utils/normalize-optimization.js +0 -2
  49. package/src/builders/application/build-action.d.ts +0 -33
  50. package/src/builders/application/build-action.js +0 -183
  51. package/src/builders/application/execute-build.d.ts +0 -11
  52. package/src/builders/application/execute-build.js +0 -125
  53. package/src/builders/application/execute-post-bundle.d.ts +0 -25
  54. package/src/builders/application/execute-post-bundle.js +0 -93
  55. package/src/builders/application/i18n.d.ts +0 -29
  56. package/src/builders/application/i18n.js +0 -128
  57. package/src/builders/application/index.d.ts +0 -57
  58. package/src/builders/application/index.js +0 -121
  59. package/src/builders/application/options.d.ts +0 -149
  60. package/src/builders/application/options.js +0 -369
  61. package/src/builders/application/schema.d.ts +0 -512
  62. package/src/builders/application/schema.js +0 -58
  63. package/src/builders/application/schema.json +0 -635
  64. package/src/builders/application/setup-bundling.d.ts +0 -19
  65. package/src/builders/application/setup-bundling.js +0 -71
  66. package/src/builders/dev-server/vite-server.d.ts +0 -30
  67. package/src/builders/dev-server/vite-server.js +0 -502
  68. package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -27
  69. package/src/tools/babel/plugins/adjust-static-class-members.js +0 -351
  70. package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -23
  71. package/src/tools/babel/plugins/adjust-typescript-enums.js +0 -113
  72. package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -23
  73. package/src/tools/babel/plugins/elide-angular-metadata.js +0 -110
  74. package/src/tools/babel/plugins/index.d.ts +0 -11
  75. package/src/tools/babel/plugins/index.js +0 -21
  76. package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -16
  77. package/src/tools/babel/plugins/pure-toplevel-functions.js +0 -90
  78. package/src/tools/esbuild/angular/angular-host.d.ts +0 -26
  79. package/src/tools/esbuild/angular/angular-host.js +0 -72
  80. package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +0 -42
  81. package/src/tools/esbuild/angular/compilation/angular-compilation.js +0 -94
  82. package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +0 -21
  83. package/src/tools/esbuild/angular/compilation/aot-compilation.js +0 -228
  84. package/src/tools/esbuild/angular/compilation/factory.d.ts +0 -16
  85. package/src/tools/esbuild/angular/compilation/factory.js +0 -56
  86. package/src/tools/esbuild/angular/compilation/index.d.ts +0 -10
  87. package/src/tools/esbuild/angular/compilation/index.js +0 -17
  88. package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +0 -21
  89. package/src/tools/esbuild/angular/compilation/jit-compilation.js +0 -106
  90. package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +0 -20
  91. package/src/tools/esbuild/angular/compilation/noop-compilation.js +0 -26
  92. package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +0 -42
  93. package/src/tools/esbuild/angular/compilation/parallel-compilation.js +0 -123
  94. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -33
  95. package/src/tools/esbuild/angular/compilation/parallel-worker.js +0 -90
  96. package/src/tools/esbuild/angular/compilation-state.d.ts +0 -15
  97. package/src/tools/esbuild/angular/compilation-state.js +0 -44
  98. package/src/tools/esbuild/angular/compiler-plugin.d.ts +0 -27
  99. package/src/tools/esbuild/angular/compiler-plugin.js +0 -441
  100. package/src/tools/esbuild/angular/component-stylesheets.d.ts +0 -44
  101. package/src/tools/esbuild/angular/component-stylesheets.js +0 -150
  102. package/src/tools/esbuild/angular/diagnostics.d.ts +0 -15
  103. package/src/tools/esbuild/angular/diagnostics.js +0 -69
  104. package/src/tools/esbuild/angular/file-reference-tracker.d.ts +0 -17
  105. package/src/tools/esbuild/angular/file-reference-tracker.js +0 -57
  106. package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +0 -23
  107. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +0 -117
  108. package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +0 -17
  109. package/src/tools/esbuild/angular/jit-resource-transformer.js +0 -186
  110. package/src/tools/esbuild/angular/source-file-cache.d.ts +0 -18
  111. package/src/tools/esbuild/angular/source-file-cache.js +0 -65
  112. package/src/tools/esbuild/angular/uri.d.ts +0 -54
  113. package/src/tools/esbuild/angular/uri.js +0 -74
  114. package/src/tools/esbuild/angular/web-worker-transformer.d.ts +0 -17
  115. package/src/tools/esbuild/angular/web-worker-transformer.js +0 -94
  116. package/src/tools/esbuild/application-code-bundle.d.ts +0 -20
  117. package/src/tools/esbuild/application-code-bundle.js +0 -368
  118. package/src/tools/esbuild/budget-stats.d.ts +0 -19
  119. package/src/tools/esbuild/budget-stats.js +0 -59
  120. package/src/tools/esbuild/bundler-context.d.ts +0 -75
  121. package/src/tools/esbuild/bundler-context.js +0 -366
  122. package/src/tools/esbuild/bundler-execution-result.d.ts +0 -71
  123. package/src/tools/esbuild/bundler-execution-result.js +0 -131
  124. package/src/tools/esbuild/cache.d.ts +0 -88
  125. package/src/tools/esbuild/cache.js +0 -92
  126. package/src/tools/esbuild/commonjs-checker.d.ts +0 -28
  127. package/src/tools/esbuild/commonjs-checker.js +0 -151
  128. package/src/tools/esbuild/compiler-plugin-options.d.ts +0 -16
  129. package/src/tools/esbuild/compiler-plugin-options.js +0 -49
  130. package/src/tools/esbuild/external-packages-plugin.d.ts +0 -18
  131. package/src/tools/esbuild/external-packages-plugin.js +0 -70
  132. package/src/tools/esbuild/global-scripts.d.ts +0 -16
  133. package/src/tools/esbuild/global-scripts.js +0 -142
  134. package/src/tools/esbuild/global-styles.d.ts +0 -10
  135. package/src/tools/esbuild/global-styles.js +0 -74
  136. package/src/tools/esbuild/i18n-inliner-worker.d.ts +0 -42
  137. package/src/tools/esbuild/i18n-inliner-worker.js +0 -136
  138. package/src/tools/esbuild/i18n-inliner.d.ts +0 -44
  139. package/src/tools/esbuild/i18n-inliner.js +0 -150
  140. package/src/tools/esbuild/i18n-locale-plugin.d.ts +0 -22
  141. package/src/tools/esbuild/i18n-locale-plugin.js +0 -120
  142. package/src/tools/esbuild/index-html-generator.d.ts +0 -15
  143. package/src/tools/esbuild/index-html-generator.js +0 -81
  144. package/src/tools/esbuild/javascript-transformer-worker.d.ts +0 -19
  145. package/src/tools/esbuild/javascript-transformer-worker.js +0 -154
  146. package/src/tools/esbuild/javascript-transformer.d.ts +0 -54
  147. package/src/tools/esbuild/javascript-transformer.js +0 -147
  148. package/src/tools/esbuild/license-extractor.d.ts +0 -25
  149. package/src/tools/esbuild/license-extractor.js +0 -158
  150. package/src/tools/esbuild/load-result-cache.d.ts +0 -21
  151. package/src/tools/esbuild/load-result-cache.js +0 -75
  152. package/src/tools/esbuild/profiling.d.ts +0 -11
  153. package/src/tools/esbuild/profiling.js +0 -78
  154. package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +0 -18
  155. package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +0 -44
  156. package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +0 -17
  157. package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +0 -73
  158. package/src/tools/esbuild/stylesheets/bundle-options.d.ts +0 -35
  159. package/src/tools/esbuild/stylesheets/bundle-options.js +0 -64
  160. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +0 -25
  161. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +0 -57
  162. package/src/tools/esbuild/stylesheets/css-language.d.ts +0 -9
  163. package/src/tools/esbuild/stylesheets/css-language.js +0 -15
  164. package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +0 -18
  165. package/src/tools/esbuild/stylesheets/css-resource-plugin.js +0 -114
  166. package/src/tools/esbuild/stylesheets/less-language.d.ts +0 -9
  167. package/src/tools/esbuild/stylesheets/less-language.js +0 -155
  168. package/src/tools/esbuild/stylesheets/sass-language.d.ts +0 -10
  169. package/src/tools/esbuild/stylesheets/sass-language.js +0 -185
  170. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +0 -58
  171. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +0 -282
  172. package/src/tools/esbuild/utils.d.ts +0 -41
  173. package/src/tools/esbuild/utils.js +0 -378
  174. package/src/tools/esbuild/virtual-module-plugin.d.ts +0 -33
  175. package/src/tools/esbuild/virtual-module-plugin.js +0 -43
  176. package/src/tools/esbuild/watcher.d.ts +0 -25
  177. package/src/tools/esbuild/watcher.js +0 -118
  178. package/src/tools/sass/lexer.d.ts +0 -18
  179. package/src/tools/sass/lexer.js +0 -161
  180. package/src/tools/sass/rebasing-importer.d.ts +0 -101
  181. package/src/tools/sass/rebasing-importer.js +0 -334
  182. package/src/tools/sass/sass-service.d.ts +0 -72
  183. package/src/tools/sass/sass-service.js +0 -213
  184. package/src/tools/sass/worker.d.ts +0 -8
  185. package/src/tools/sass/worker.js +0 -192
  186. package/src/tools/vite/angular-memory-plugin.d.ts +0 -24
  187. package/src/tools/vite/angular-memory-plugin.js +0 -268
  188. package/src/tools/vite/i18n-locale-plugin.d.ts +0 -18
  189. package/src/tools/vite/i18n-locale-plugin.js +0 -55
  190. package/src/typings.d.ts +0 -21
  191. package/src/utils/bundle-calculator.d.ts +0 -44
  192. package/src/utils/bundle-calculator.js +0 -303
  193. package/src/utils/check-port.d.ts +0 -8
  194. package/src/utils/check-port.js +0 -58
  195. package/src/utils/delete-output-dir.d.ts +0 -11
  196. package/src/utils/delete-output-dir.js +0 -46
  197. package/src/utils/format-bytes.d.ts +0 -8
  198. package/src/utils/format-bytes.js +0 -22
  199. package/src/utils/i18n-options.d.ts +0 -33
  200. package/src/utils/i18n-options.js +0 -161
  201. package/src/utils/index-file/add-event-dispatch-contract.d.ts +0 -8
  202. package/src/utils/index-file/add-event-dispatch-contract.js +0 -28
  203. package/src/utils/index-file/augment-index-html.d.ts +0 -40
  204. package/src/utils/index-file/augment-index-html.js +0 -239
  205. package/src/utils/index-file/html-rewriting-stream.d.ts +0 -11
  206. package/src/utils/index-file/html-rewriting-stream.js +0 -28
  207. package/src/utils/index-file/index-html-generator.d.ts +0 -57
  208. package/src/utils/index-file/index-html-generator.js +0 -135
  209. package/src/utils/index-file/inline-critical-css.d.ts +0 -24
  210. package/src/utils/index-file/inline-critical-css.js +0 -179
  211. package/src/utils/index-file/inline-fonts.d.ts +0 -23
  212. package/src/utils/index-file/inline-fonts.js +0 -267
  213. package/src/utils/index-file/nonce.d.ts +0 -12
  214. package/src/utils/index-file/nonce.js +0 -55
  215. package/src/utils/load-proxy-config.d.ts +0 -8
  216. package/src/utils/load-proxy-config.js +0 -189
  217. package/src/utils/load-translations.d.ts +0 -16
  218. package/src/utils/load-translations.js +0 -84
  219. package/src/utils/postcss-configuration.d.ts +0 -17
  220. package/src/utils/postcss-configuration.js +0 -86
  221. package/src/utils/purge-cache.d.ts +0 -10
  222. package/src/utils/purge-cache.js +0 -40
  223. package/src/utils/resolve-assets.d.ts +0 -18
  224. package/src/utils/resolve-assets.js +0 -35
  225. package/src/utils/routes-extractor/extractor.d.ts +0 -15
  226. package/src/utils/routes-extractor/extractor.js +0 -97
  227. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +0 -18
  228. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -129
  229. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +0 -8
  230. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +0 -13
  231. package/src/utils/server-rendering/fetch-patch.d.ts +0 -8
  232. package/src/utils/server-rendering/fetch-patch.js +0 -66
  233. package/src/utils/server-rendering/load-esm-from-memory.d.ts +0 -10
  234. package/src/utils/server-rendering/load-esm-from-memory.js +0 -26
  235. package/src/utils/server-rendering/main-bundle-exports.d.ts +0 -27
  236. package/src/utils/server-rendering/main-bundle-exports.js +0 -9
  237. package/src/utils/server-rendering/prerender.d.ts +0 -23
  238. package/src/utils/server-rendering/prerender.js +0 -192
  239. package/src/utils/server-rendering/render-page.d.ts +0 -26
  240. package/src/utils/server-rendering/render-page.js +0 -110
  241. package/src/utils/server-rendering/render-worker.d.ts +0 -22
  242. package/src/utils/server-rendering/render-worker.js +0 -30
  243. package/src/utils/server-rendering/routes-extractor-worker.d.ts +0 -21
  244. package/src/utils/server-rendering/routes-extractor-worker.js +0 -53
  245. package/src/utils/service-worker.d.ts +0 -25
  246. package/src/utils/service-worker.js +0 -211
  247. package/src/utils/stats-table.d.ts +0 -20
  248. package/src/utils/stats-table.js +0 -205
  249. package/src/utils/supported-browsers.d.ts +0 -10
  250. package/src/utils/supported-browsers.js +0 -42
  251. package/src/utils/version.d.ts +0 -8
  252. package/src/utils/version.js +0 -59
@@ -1,17 +0,0 @@
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.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.NoopCompilation = exports.createAngularCompilation = exports.DiagnosticModes = exports.AngularCompilation = void 0;
11
- var angular_compilation_1 = require("./angular-compilation");
12
- Object.defineProperty(exports, "AngularCompilation", { enumerable: true, get: function () { return angular_compilation_1.AngularCompilation; } });
13
- Object.defineProperty(exports, "DiagnosticModes", { enumerable: true, get: function () { return angular_compilation_1.DiagnosticModes; } });
14
- var factory_1 = require("./factory");
15
- Object.defineProperty(exports, "createAngularCompilation", { enumerable: true, get: function () { return factory_1.createAngularCompilation; } });
16
- var noop_compilation_1 = require("./noop-compilation");
17
- Object.defineProperty(exports, "NoopCompilation", { enumerable: true, get: function () { return noop_compilation_1.NoopCompilation; } });
@@ -1,21 +0,0 @@
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.io/license
7
- */
8
- import type ng from '@angular/compiler-cli';
9
- import ts from 'typescript';
10
- import { AngularHostOptions } from '../angular-host';
11
- import { AngularCompilation, DiagnosticModes, EmitFileResult } from './angular-compilation';
12
- export declare class JitCompilation extends AngularCompilation {
13
- #private;
14
- initialize(tsconfig: string, hostOptions: AngularHostOptions, compilerOptionsTransformer?: (compilerOptions: ng.CompilerOptions) => ng.CompilerOptions): Promise<{
15
- affectedFiles: ReadonlySet<ts.SourceFile>;
16
- compilerOptions: ng.CompilerOptions;
17
- referencedFiles: readonly string[];
18
- }>;
19
- collectDiagnostics(modes: DiagnosticModes): Iterable<ts.Diagnostic>;
20
- emitAffectedFiles(): Iterable<EmitFileResult>;
21
- }
@@ -1,106 +0,0 @@
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.io/license
8
- */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.JitCompilation = void 0;
14
- const node_assert_1 = __importDefault(require("node:assert"));
15
- const typescript_1 = __importDefault(require("typescript"));
16
- const profiling_1 = require("../../profiling");
17
- const angular_host_1 = require("../angular-host");
18
- const jit_resource_transformer_1 = require("../jit-resource-transformer");
19
- const web_worker_transformer_1 = require("../web-worker-transformer");
20
- const angular_compilation_1 = require("./angular-compilation");
21
- class JitCompilationState {
22
- compilerHost;
23
- typeScriptProgram;
24
- constructorParametersDownlevelTransform;
25
- replaceResourcesTransform;
26
- webWorkerTransform;
27
- constructor(compilerHost, typeScriptProgram, constructorParametersDownlevelTransform, replaceResourcesTransform, webWorkerTransform) {
28
- this.compilerHost = compilerHost;
29
- this.typeScriptProgram = typeScriptProgram;
30
- this.constructorParametersDownlevelTransform = constructorParametersDownlevelTransform;
31
- this.replaceResourcesTransform = replaceResourcesTransform;
32
- this.webWorkerTransform = webWorkerTransform;
33
- }
34
- }
35
- class JitCompilation extends angular_compilation_1.AngularCompilation {
36
- #state;
37
- async initialize(tsconfig, hostOptions, compilerOptionsTransformer) {
38
- // Dynamically load the Angular compiler CLI package
39
- const { constructorParametersDownlevelTransform } = await angular_compilation_1.AngularCompilation.loadCompilerCli();
40
- // Load the compiler configuration and transform as needed
41
- const { options: originalCompilerOptions, rootNames, errors: configurationDiagnostics, } = await this.loadConfiguration(tsconfig);
42
- const compilerOptions = compilerOptionsTransformer?.(originalCompilerOptions) ?? originalCompilerOptions;
43
- // Create Angular compiler host
44
- const host = (0, angular_host_1.createAngularCompilerHost)(compilerOptions, hostOptions);
45
- // Create the TypeScript Program
46
- const typeScriptProgram = (0, profiling_1.profileSync)('TS_CREATE_PROGRAM', () => typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, this.#state?.typeScriptProgram ?? typescript_1.default.readBuilderProgram(compilerOptions, host), configurationDiagnostics));
47
- const affectedFiles = (0, profiling_1.profileSync)('TS_FIND_AFFECTED', () => findAffectedFiles(typeScriptProgram));
48
- this.#state = new JitCompilationState(host, typeScriptProgram, constructorParametersDownlevelTransform(typeScriptProgram.getProgram()), (0, jit_resource_transformer_1.createJitResourceTransformer)(() => typeScriptProgram.getProgram().getTypeChecker()), (0, web_worker_transformer_1.createWorkerTransformer)(hostOptions.processWebWorker.bind(hostOptions)));
49
- const referencedFiles = typeScriptProgram
50
- .getSourceFiles()
51
- .map((sourceFile) => sourceFile.fileName);
52
- return { affectedFiles, compilerOptions, referencedFiles };
53
- }
54
- *collectDiagnostics(modes) {
55
- (0, node_assert_1.default)(this.#state, 'Compilation must be initialized prior to collecting diagnostics.');
56
- const { typeScriptProgram } = this.#state;
57
- // Collect program level diagnostics
58
- if (modes & angular_compilation_1.DiagnosticModes.Option) {
59
- yield* typeScriptProgram.getConfigFileParsingDiagnostics();
60
- yield* typeScriptProgram.getOptionsDiagnostics();
61
- }
62
- if (modes & angular_compilation_1.DiagnosticModes.Syntactic) {
63
- yield* typeScriptProgram.getGlobalDiagnostics();
64
- yield* (0, profiling_1.profileSync)('NG_DIAGNOSTICS_SYNTACTIC', () => typeScriptProgram.getSyntacticDiagnostics());
65
- }
66
- if (modes & angular_compilation_1.DiagnosticModes.Semantic) {
67
- yield* (0, profiling_1.profileSync)('NG_DIAGNOSTICS_SEMANTIC', () => typeScriptProgram.getSemanticDiagnostics());
68
- }
69
- }
70
- emitAffectedFiles() {
71
- (0, node_assert_1.default)(this.#state, 'Compilation must be initialized prior to emitting files.');
72
- const { compilerHost, typeScriptProgram, constructorParametersDownlevelTransform, replaceResourcesTransform, webWorkerTransform, } = this.#state;
73
- const buildInfoFilename = typeScriptProgram.getCompilerOptions().tsBuildInfoFile ?? '.tsbuildinfo';
74
- const emittedFiles = [];
75
- const writeFileCallback = (filename, contents, _a, _b, sourceFiles) => {
76
- if (!sourceFiles?.length && filename.endsWith(buildInfoFilename)) {
77
- // Save builder info contents to specified location
78
- compilerHost.writeFile(filename, contents, false);
79
- return;
80
- }
81
- (0, node_assert_1.default)(sourceFiles?.length === 1, 'Invalid TypeScript program emit for ' + filename);
82
- emittedFiles.push({ filename: sourceFiles[0].fileName, contents });
83
- };
84
- const transformers = {
85
- before: [
86
- replaceResourcesTransform,
87
- constructorParametersDownlevelTransform,
88
- webWorkerTransform,
89
- ],
90
- };
91
- // TypeScript will loop until there are no more affected files in the program
92
- while (typeScriptProgram.emitNextAffectedFile(writeFileCallback, undefined, undefined, transformers)) {
93
- /* empty */
94
- }
95
- return emittedFiles;
96
- }
97
- }
98
- exports.JitCompilation = JitCompilation;
99
- function findAffectedFiles(builder) {
100
- const affectedFiles = new Set();
101
- let result;
102
- while ((result = builder.getSemanticDiagnosticsOfNextAffectedFile())) {
103
- affectedFiles.add(result.affected);
104
- }
105
- return affectedFiles;
106
- }
@@ -1,20 +0,0 @@
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.io/license
7
- */
8
- import type ng from '@angular/compiler-cli';
9
- import type ts from 'typescript';
10
- import { AngularHostOptions } from '../angular-host';
11
- import { AngularCompilation } from './angular-compilation';
12
- export declare class NoopCompilation extends AngularCompilation {
13
- initialize(tsconfig: string, hostOptions: AngularHostOptions, compilerOptionsTransformer?: (compilerOptions: ng.CompilerOptions) => ng.CompilerOptions): Promise<{
14
- affectedFiles: ReadonlySet<ts.SourceFile>;
15
- compilerOptions: ng.CompilerOptions;
16
- referencedFiles: readonly string[];
17
- }>;
18
- collectDiagnostics(): never;
19
- emitAffectedFiles(): never;
20
- }
@@ -1,26 +0,0 @@
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.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.NoopCompilation = void 0;
11
- const angular_compilation_1 = require("./angular-compilation");
12
- class NoopCompilation extends angular_compilation_1.AngularCompilation {
13
- async initialize(tsconfig, hostOptions, compilerOptionsTransformer) {
14
- // Load the compiler configuration and transform as needed
15
- const { options: originalCompilerOptions } = await this.loadConfiguration(tsconfig);
16
- const compilerOptions = compilerOptionsTransformer?.(originalCompilerOptions) ?? originalCompilerOptions;
17
- return { affectedFiles: new Set(), compilerOptions, referencedFiles: [] };
18
- }
19
- collectDiagnostics() {
20
- throw new Error('Not available when using noop compilation.');
21
- }
22
- emitAffectedFiles() {
23
- throw new Error('Not available when using noop compilation.');
24
- }
25
- }
26
- exports.NoopCompilation = NoopCompilation;
@@ -1,42 +0,0 @@
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.io/license
7
- */
8
- import type { CompilerOptions } from '@angular/compiler-cli';
9
- import type { PartialMessage } from 'esbuild';
10
- import type { SourceFile } from 'typescript';
11
- import type { AngularHostOptions } from '../angular-host';
12
- import { AngularCompilation, DiagnosticModes, EmitFileResult } from './angular-compilation';
13
- /**
14
- * An Angular compilation which uses a Node.js Worker thread to load and execute
15
- * the TypeScript and Angular compilers. This allows for longer synchronous actions
16
- * such as semantic and template diagnostics to be calculated in parallel to the
17
- * other aspects of the application bundling process. The worker thread also has
18
- * a separate memory pool which significantly reduces the need for adjusting the
19
- * main Node.js CLI process memory settings with large application code sizes.
20
- */
21
- export declare class ParallelCompilation extends AngularCompilation {
22
- #private;
23
- readonly jit: boolean;
24
- constructor(jit: boolean);
25
- initialize(tsconfig: string, hostOptions: AngularHostOptions, compilerOptionsTransformer?: ((compilerOptions: CompilerOptions) => CompilerOptions) | undefined): Promise<{
26
- affectedFiles: ReadonlySet<SourceFile>;
27
- compilerOptions: CompilerOptions;
28
- referencedFiles: readonly string[];
29
- }>;
30
- /**
31
- * This is not needed with this compilation type since the worker will already send a response
32
- * with the serializable esbuild compatible diagnostics.
33
- */
34
- protected collectDiagnostics(): never;
35
- diagnoseFiles(modes?: DiagnosticModes): Promise<{
36
- errors?: PartialMessage[];
37
- warnings?: PartialMessage[];
38
- }>;
39
- emitAffectedFiles(): Promise<Iterable<EmitFileResult>>;
40
- update(files: Set<string>): Promise<void>;
41
- close(): Promise<void>;
42
- }
@@ -1,123 +0,0 @@
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.io/license
8
- */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.ParallelCompilation = void 0;
14
- const node_module_1 = require("node:module");
15
- const node_worker_threads_1 = require("node:worker_threads");
16
- const piscina_1 = __importDefault(require("piscina"));
17
- const angular_compilation_1 = require("./angular-compilation");
18
- /**
19
- * An Angular compilation which uses a Node.js Worker thread to load and execute
20
- * the TypeScript and Angular compilers. This allows for longer synchronous actions
21
- * such as semantic and template diagnostics to be calculated in parallel to the
22
- * other aspects of the application bundling process. The worker thread also has
23
- * a separate memory pool which significantly reduces the need for adjusting the
24
- * main Node.js CLI process memory settings with large application code sizes.
25
- */
26
- class ParallelCompilation extends angular_compilation_1.AngularCompilation {
27
- jit;
28
- #worker;
29
- constructor(jit) {
30
- super();
31
- this.jit = jit;
32
- // TODO: Convert to import.meta usage during ESM transition
33
- const localRequire = (0, node_module_1.createRequire)(__filename);
34
- this.#worker = new piscina_1.default({
35
- minThreads: 1,
36
- maxThreads: 1,
37
- idleTimeout: Infinity,
38
- // Web containers do not support transferable objects with receiveOnMessagePort which
39
- // is used when the Atomics based wait loop is enable.
40
- useAtomics: !process.versions.webcontainer,
41
- filename: localRequire.resolve('./parallel-worker'),
42
- recordTiming: false,
43
- });
44
- }
45
- initialize(tsconfig, hostOptions, compilerOptionsTransformer) {
46
- const stylesheetChannel = new node_worker_threads_1.MessageChannel();
47
- // The request identifier is required because Angular can issue multiple concurrent requests
48
- stylesheetChannel.port1.on('message', ({ requestId, data, containingFile, stylesheetFile }) => {
49
- hostOptions
50
- .transformStylesheet(data, containingFile, stylesheetFile)
51
- .then((value) => stylesheetChannel.port1.postMessage({ requestId, value }))
52
- .catch((error) => stylesheetChannel.port1.postMessage({ requestId, error }));
53
- });
54
- // The web worker processing is a synchronous operation and uses shared memory combined with
55
- // the Atomics API to block execution here until a response is received.
56
- const webWorkerChannel = new node_worker_threads_1.MessageChannel();
57
- const webWorkerSignal = new Int32Array(new SharedArrayBuffer(4));
58
- webWorkerChannel.port1.on('message', ({ workerFile, containingFile }) => {
59
- try {
60
- const workerCodeFile = hostOptions.processWebWorker(workerFile, containingFile);
61
- webWorkerChannel.port1.postMessage({ workerCodeFile });
62
- }
63
- catch (error) {
64
- webWorkerChannel.port1.postMessage({ error });
65
- }
66
- finally {
67
- Atomics.store(webWorkerSignal, 0, 1);
68
- Atomics.notify(webWorkerSignal, 0);
69
- }
70
- });
71
- // The compiler options transformation is a synchronous operation and uses shared memory combined
72
- // with the Atomics API to block execution here until a response is received.
73
- const optionsChannel = new node_worker_threads_1.MessageChannel();
74
- const optionsSignal = new Int32Array(new SharedArrayBuffer(4));
75
- optionsChannel.port1.on('message', (compilerOptions) => {
76
- try {
77
- const transformedOptions = compilerOptionsTransformer?.(compilerOptions) ?? compilerOptions;
78
- optionsChannel.port1.postMessage({ transformedOptions });
79
- }
80
- catch (error) {
81
- webWorkerChannel.port1.postMessage({ error });
82
- }
83
- finally {
84
- Atomics.store(optionsSignal, 0, 1);
85
- Atomics.notify(optionsSignal, 0);
86
- }
87
- });
88
- // Execute the initialize function in the worker thread
89
- return this.#worker.run({
90
- fileReplacements: hostOptions.fileReplacements,
91
- tsconfig,
92
- jit: this.jit,
93
- stylesheetPort: stylesheetChannel.port2,
94
- optionsPort: optionsChannel.port2,
95
- optionsSignal,
96
- webWorkerPort: webWorkerChannel.port2,
97
- webWorkerSignal,
98
- }, {
99
- name: 'initialize',
100
- transferList: [stylesheetChannel.port2, optionsChannel.port2, webWorkerChannel.port2],
101
- });
102
- }
103
- /**
104
- * This is not needed with this compilation type since the worker will already send a response
105
- * with the serializable esbuild compatible diagnostics.
106
- */
107
- collectDiagnostics() {
108
- throw new Error('Not implemented in ParallelCompilation.');
109
- }
110
- diagnoseFiles(modes = angular_compilation_1.DiagnosticModes.All) {
111
- return this.#worker.run(modes, { name: 'diagnose' });
112
- }
113
- emitAffectedFiles() {
114
- return this.#worker.run(undefined, { name: 'emit' });
115
- }
116
- update(files) {
117
- return this.#worker.run(files, { name: 'update' });
118
- }
119
- close() {
120
- return this.#worker.destroy();
121
- }
122
- }
123
- exports.ParallelCompilation = ParallelCompilation;
@@ -1,33 +0,0 @@
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.io/license
7
- */
8
- /// <reference types="node" />
9
- import type { PartialMessage } from 'esbuild';
10
- import { type MessagePort } from 'node:worker_threads';
11
- import type { DiagnosticModes } from './angular-compilation';
12
- export interface InitRequest {
13
- jit: boolean;
14
- tsconfig: string;
15
- fileReplacements?: Record<string, string>;
16
- stylesheetPort: MessagePort;
17
- optionsPort: MessagePort;
18
- optionsSignal: Int32Array;
19
- webWorkerPort: MessagePort;
20
- webWorkerSignal: Int32Array;
21
- }
22
- export declare function initialize(request: InitRequest): Promise<{
23
- referencedFiles: readonly string[];
24
- compilerOptions: {
25
- allowJs: boolean | undefined;
26
- };
27
- }>;
28
- export declare function diagnose(modes: DiagnosticModes): Promise<{
29
- errors?: PartialMessage[];
30
- warnings?: PartialMessage[];
31
- }>;
32
- export declare function emit(): Promise<import("./angular-compilation").EmitFileResult[]>;
33
- export declare function update(files: Set<string>): void;
@@ -1,90 +0,0 @@
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.io/license
8
- */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.update = exports.emit = exports.diagnose = exports.initialize = void 0;
14
- const node_assert_1 = __importDefault(require("node:assert"));
15
- const node_crypto_1 = require("node:crypto");
16
- const node_worker_threads_1 = require("node:worker_threads");
17
- const source_file_cache_1 = require("../source-file-cache");
18
- const aot_compilation_1 = require("./aot-compilation");
19
- const jit_compilation_1 = require("./jit-compilation");
20
- let compilation;
21
- const sourceFileCache = new source_file_cache_1.SourceFileCache();
22
- async function initialize(request) {
23
- compilation ??= request.jit ? new jit_compilation_1.JitCompilation() : new aot_compilation_1.AotCompilation();
24
- const stylesheetRequests = new Map();
25
- request.stylesheetPort.on('message', ({ requestId, value, error }) => {
26
- if (error) {
27
- stylesheetRequests.get(requestId)?.[1](error);
28
- }
29
- else {
30
- stylesheetRequests.get(requestId)?.[0](value);
31
- }
32
- });
33
- const { compilerOptions, referencedFiles } = await compilation.initialize(request.tsconfig, {
34
- fileReplacements: request.fileReplacements,
35
- sourceFileCache,
36
- modifiedFiles: sourceFileCache.modifiedFiles,
37
- transformStylesheet(data, containingFile, stylesheetFile) {
38
- const requestId = (0, node_crypto_1.randomUUID)();
39
- const resultPromise = new Promise((resolve, reject) => stylesheetRequests.set(requestId, [resolve, reject]));
40
- request.stylesheetPort.postMessage({
41
- requestId,
42
- data,
43
- containingFile,
44
- stylesheetFile,
45
- });
46
- return resultPromise;
47
- },
48
- processWebWorker(workerFile, containingFile) {
49
- Atomics.store(request.webWorkerSignal, 0, 0);
50
- request.webWorkerPort.postMessage({ workerFile, containingFile });
51
- Atomics.wait(request.webWorkerSignal, 0, 0);
52
- const result = (0, node_worker_threads_1.receiveMessageOnPort)(request.webWorkerPort)?.message;
53
- if (result?.error) {
54
- throw result.error;
55
- }
56
- return result?.workerCodeFile ?? workerFile;
57
- },
58
- }, (compilerOptions) => {
59
- Atomics.store(request.optionsSignal, 0, 0);
60
- request.optionsPort.postMessage(compilerOptions);
61
- Atomics.wait(request.optionsSignal, 0, 0);
62
- const result = (0, node_worker_threads_1.receiveMessageOnPort)(request.optionsPort)?.message;
63
- if (result?.error) {
64
- throw result.error;
65
- }
66
- return result?.transformedOptions ?? compilerOptions;
67
- });
68
- return {
69
- referencedFiles,
70
- // TODO: Expand? `allowJs` is the only field needed currently.
71
- compilerOptions: { allowJs: compilerOptions.allowJs },
72
- };
73
- }
74
- exports.initialize = initialize;
75
- async function diagnose(modes) {
76
- (0, node_assert_1.default)(compilation);
77
- const diagnostics = await compilation.diagnoseFiles(modes);
78
- return diagnostics;
79
- }
80
- exports.diagnose = diagnose;
81
- async function emit() {
82
- (0, node_assert_1.default)(compilation);
83
- const files = await compilation.emitAffectedFiles();
84
- return [...files];
85
- }
86
- exports.emit = emit;
87
- function update(files) {
88
- sourceFileCache.invalidate(files);
89
- }
90
- exports.update = update;
@@ -1,15 +0,0 @@
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.io/license
7
- */
8
- export declare class SharedTSCompilationState {
9
- #private;
10
- get waitUntilReady(): Promise<boolean>;
11
- markAsReady(hasErrors: boolean): void;
12
- markAsInProgress(): void;
13
- dispose(): void;
14
- }
15
- export declare function getSharedCompilationState(): SharedTSCompilationState;
@@ -1,44 +0,0 @@
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.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getSharedCompilationState = exports.SharedTSCompilationState = void 0;
11
- class SharedTSCompilationState {
12
- #pendingCompilation = true;
13
- #resolveCompilationReady;
14
- #compilationReadyPromise;
15
- #hasErrors = true;
16
- get waitUntilReady() {
17
- if (!this.#pendingCompilation) {
18
- return Promise.resolve(this.#hasErrors);
19
- }
20
- this.#compilationReadyPromise ??= new Promise((resolve) => {
21
- this.#resolveCompilationReady = resolve;
22
- });
23
- return this.#compilationReadyPromise;
24
- }
25
- markAsReady(hasErrors) {
26
- this.#hasErrors = hasErrors;
27
- this.#resolveCompilationReady?.(hasErrors);
28
- this.#compilationReadyPromise = undefined;
29
- this.#pendingCompilation = false;
30
- }
31
- markAsInProgress() {
32
- this.#pendingCompilation = true;
33
- }
34
- dispose() {
35
- this.markAsReady(true);
36
- globalSharedCompilationState = undefined;
37
- }
38
- }
39
- exports.SharedTSCompilationState = SharedTSCompilationState;
40
- let globalSharedCompilationState;
41
- function getSharedCompilationState() {
42
- return (globalSharedCompilationState ??= new SharedTSCompilationState());
43
- }
44
- exports.getSharedCompilationState = getSharedCompilationState;
@@ -1,27 +0,0 @@
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.io/license
7
- */
8
- import type { Plugin } from 'esbuild';
9
- import { LoadResultCache } from '../load-result-cache';
10
- import { BundleStylesheetOptions } from '../stylesheets/bundle-options';
11
- import { SourceFileCache } from './source-file-cache';
12
- export interface CompilerPluginOptions {
13
- sourcemap: boolean;
14
- tsconfig: string;
15
- jit?: boolean;
16
- /** Skip TypeScript compilation setup. This is useful to re-use the TypeScript compilation from another plugin. */
17
- noopTypeScriptCompilation?: boolean;
18
- advancedOptimizations?: boolean;
19
- thirdPartySourcemaps?: boolean;
20
- fileReplacements?: Record<string, string>;
21
- sourceFileCache?: SourceFileCache;
22
- loadResultCache?: LoadResultCache;
23
- incremental: boolean;
24
- }
25
- export declare function createCompilerPlugin(pluginOptions: CompilerPluginOptions, styleOptions: BundleStylesheetOptions & {
26
- inlineStyleLanguage: string;
27
- }): Plugin;