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

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,22 +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 { ESMInMemoryFileLoaderWorkerData } from './esm-in-memory-loader/loader-hooks';
9
- import { RenderResult, ServerContext } from './render-page';
10
- export interface RenderWorkerData extends ESMInMemoryFileLoaderWorkerData {
11
- document: string;
12
- inlineCriticalCss?: boolean;
13
- assetFiles: Record</** Destination */ string, /** Source */ string>;
14
- }
15
- export interface RenderOptions {
16
- route: string;
17
- serverContext: ServerContext;
18
- }
19
- /** Renders an application based on a provided options. */
20
- declare function render(options: RenderOptions): Promise<RenderResult>;
21
- declare const _default: typeof render;
22
- export default _default;
@@ -1,30 +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
- const node_worker_threads_1 = require("node:worker_threads");
11
- const fetch_patch_1 = require("./fetch-patch");
12
- const render_page_1 = require("./render-page");
13
- /**
14
- * This is passed as workerData when setting up the worker via the `piscina` package.
15
- */
16
- const { outputFiles, document, inlineCriticalCss } = node_worker_threads_1.workerData;
17
- /** Renders an application based on a provided options. */
18
- function render(options) {
19
- return (0, render_page_1.renderPage)({
20
- ...options,
21
- outputFiles,
22
- document,
23
- inlineCriticalCss,
24
- });
25
- }
26
- function initialize() {
27
- (0, fetch_patch_1.patchFetchToLoadInMemoryAssets)();
28
- return render;
29
- }
30
- exports.default = initialize();
@@ -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 { ESMInMemoryFileLoaderWorkerData } from './esm-in-memory-loader/loader-hooks';
9
- export interface RoutesExtractorWorkerData extends ESMInMemoryFileLoaderWorkerData {
10
- document: string;
11
- verbose: boolean;
12
- assetFiles: Record</** Destination */ string, /** Source */ string>;
13
- }
14
- export interface RoutersExtractorWorkerResult {
15
- routes: string[];
16
- warnings?: string[];
17
- }
18
- /** Renders an application based on a provided options. */
19
- declare function extractRoutes(): Promise<RoutersExtractorWorkerResult>;
20
- declare const _default: typeof extractRoutes;
21
- export default _default;
@@ -1,53 +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
- const node_worker_threads_1 = require("node:worker_threads");
11
- const fetch_patch_1 = require("./fetch-patch");
12
- const load_esm_from_memory_1 = require("./load-esm-from-memory");
13
- /**
14
- * This is passed as workerData when setting up the worker via the `piscina` package.
15
- */
16
- const { document, verbose } = node_worker_threads_1.workerData;
17
- /** Renders an application based on a provided options. */
18
- async function extractRoutes() {
19
- const { extractRoutes } = await (0, load_esm_from_memory_1.loadEsmModuleFromMemory)('./render-utils.server.mjs');
20
- const { default: bootstrapAppFnOrModule } = await (0, load_esm_from_memory_1.loadEsmModuleFromMemory)('./main.server.mjs');
21
- const skippedRedirects = [];
22
- const skippedOthers = [];
23
- const routes = [];
24
- for await (const { route, success, redirect } of extractRoutes(bootstrapAppFnOrModule, document)) {
25
- if (success) {
26
- routes.push(route);
27
- continue;
28
- }
29
- if (redirect) {
30
- skippedRedirects.push(route);
31
- }
32
- else {
33
- skippedOthers.push(route);
34
- }
35
- }
36
- if (!verbose) {
37
- return { routes };
38
- }
39
- let warnings;
40
- if (skippedOthers.length) {
41
- (warnings ??= []).push('The following routes were skipped from prerendering because they contain routes with dynamic parameters:\n' +
42
- skippedOthers.join('\n'));
43
- }
44
- if (skippedRedirects.length) {
45
- (warnings ??= []).push('The following routes were skipped from prerendering because they contain redirects:\n', skippedRedirects.join('\n'));
46
- }
47
- return { routes, warnings };
48
- }
49
- function initialize() {
50
- (0, fetch_patch_1.patchFetchToLoadInMemoryAssets)();
51
- return extractRoutes;
52
- }
53
- exports.default = initialize();
@@ -1,25 +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
- /// <reference types="node" />
10
- import type { Config, Filesystem } from '@angular/service-worker/config';
11
- import { promises as fsPromises } from 'node:fs';
12
- import { BuildOutputFile } from '../tools/esbuild/bundler-context';
13
- import { BuildOutputAsset } from '../tools/esbuild/bundler-execution-result';
14
- export declare function augmentAppWithServiceWorker(appRoot: string, workspaceRoot: string, outputPath: string, baseHref: string, ngswConfigPath?: string, inputputFileSystem?: typeof fsPromises, outputFileSystem?: typeof fsPromises): Promise<void>;
15
- export declare function augmentAppWithServiceWorkerEsbuild(workspaceRoot: string, configPath: string, baseHref: string, indexHtml: string | undefined, outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[]): Promise<{
16
- manifest: string;
17
- assetFiles: BuildOutputAsset[];
18
- }>;
19
- export declare function augmentAppWithServiceWorkerCore(config: Config, serviceWorkerFilesystem: Filesystem, baseHref: string): Promise<{
20
- manifest: string;
21
- assetFiles: {
22
- source: string;
23
- destination: string;
24
- }[];
25
- }>;
@@ -1,211 +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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.augmentAppWithServiceWorkerCore = exports.augmentAppWithServiceWorkerEsbuild = exports.augmentAppWithServiceWorker = void 0;
34
- const crypto = __importStar(require("crypto"));
35
- const node_fs_1 = require("node:fs");
36
- const path = __importStar(require("path"));
37
- const bundler_context_1 = require("../tools/esbuild/bundler-context");
38
- const error_1 = require("./error");
39
- const load_esm_1 = require("./load-esm");
40
- class CliFilesystem {
41
- fs;
42
- base;
43
- constructor(fs, base) {
44
- this.fs = fs;
45
- this.base = base;
46
- }
47
- list(dir) {
48
- return this._recursiveList(this._resolve(dir), []);
49
- }
50
- read(file) {
51
- return this.fs.readFile(this._resolve(file), 'utf-8');
52
- }
53
- async hash(file) {
54
- return crypto
55
- .createHash('sha1')
56
- .update(await this.fs.readFile(this._resolve(file)))
57
- .digest('hex');
58
- }
59
- write(_file, _content) {
60
- throw new Error('This should never happen.');
61
- }
62
- _resolve(file) {
63
- return path.join(this.base, file);
64
- }
65
- async _recursiveList(dir, items) {
66
- const subdirectories = [];
67
- for (const entry of await this.fs.readdir(dir)) {
68
- const entryPath = path.join(dir, entry);
69
- const stats = await this.fs.stat(entryPath);
70
- if (stats.isFile()) {
71
- // Uses posix paths since the service worker expects URLs
72
- items.push('/' + path.relative(this.base, entryPath).replace(/\\/g, '/'));
73
- }
74
- else if (stats.isDirectory()) {
75
- subdirectories.push(entryPath);
76
- }
77
- }
78
- for (const subdirectory of subdirectories) {
79
- await this._recursiveList(subdirectory, items);
80
- }
81
- return items;
82
- }
83
- }
84
- class ResultFilesystem {
85
- fileReaders = new Map();
86
- constructor(outputFiles, assetFiles) {
87
- for (const file of outputFiles) {
88
- if (file.type === bundler_context_1.BuildOutputFileType.Media || file.type === bundler_context_1.BuildOutputFileType.Browser) {
89
- this.fileReaders.set('/' + file.path.replace(/\\/g, '/'), async () => file.contents);
90
- }
91
- }
92
- for (const file of assetFiles) {
93
- this.fileReaders.set('/' + file.destination.replace(/\\/g, '/'), () => node_fs_1.promises.readFile(file.source));
94
- }
95
- }
96
- async list(dir) {
97
- if (dir !== '/') {
98
- throw new Error('Serviceworker manifest generator should only list files from root.');
99
- }
100
- return [...this.fileReaders.keys()];
101
- }
102
- async read(file) {
103
- const reader = this.fileReaders.get(file);
104
- if (reader === undefined) {
105
- throw new Error('File does not exist.');
106
- }
107
- const contents = await reader();
108
- return Buffer.from(contents.buffer, contents.byteOffset, contents.byteLength).toString('utf-8');
109
- }
110
- async hash(file) {
111
- const reader = this.fileReaders.get(file);
112
- if (reader === undefined) {
113
- throw new Error('File does not exist.');
114
- }
115
- return crypto
116
- .createHash('sha1')
117
- .update(await reader())
118
- .digest('hex');
119
- }
120
- write() {
121
- throw new Error('Serviceworker manifest generator should not attempted to write.');
122
- }
123
- }
124
- async function augmentAppWithServiceWorker(appRoot, workspaceRoot, outputPath, baseHref, ngswConfigPath, inputputFileSystem = node_fs_1.promises, outputFileSystem = node_fs_1.promises) {
125
- // Determine the configuration file path
126
- const configPath = ngswConfigPath
127
- ? path.join(workspaceRoot, ngswConfigPath)
128
- : path.join(appRoot, 'ngsw-config.json');
129
- // Read the configuration file
130
- let config;
131
- try {
132
- const configurationData = await inputputFileSystem.readFile(configPath, 'utf-8');
133
- config = JSON.parse(configurationData);
134
- }
135
- catch (error) {
136
- (0, error_1.assertIsError)(error);
137
- if (error.code === 'ENOENT') {
138
- throw new Error('Error: Expected to find an ngsw-config.json configuration file' +
139
- ` in the ${appRoot} folder. Either provide one or` +
140
- ' disable Service Worker in the angular.json configuration file.');
141
- }
142
- else {
143
- throw error;
144
- }
145
- }
146
- const result = await augmentAppWithServiceWorkerCore(config, new CliFilesystem(outputFileSystem, outputPath), baseHref);
147
- const copy = async (src, dest) => {
148
- const resolvedDest = path.join(outputPath, dest);
149
- return inputputFileSystem === outputFileSystem
150
- ? // Native FS (Builder).
151
- inputputFileSystem.copyFile(src, resolvedDest, node_fs_1.constants.COPYFILE_FICLONE)
152
- : // memfs (Webpack): Read the file from the input FS (disk) and write it to the output FS (memory).
153
- outputFileSystem.writeFile(resolvedDest, await inputputFileSystem.readFile(src));
154
- };
155
- await outputFileSystem.writeFile(path.join(outputPath, 'ngsw.json'), result.manifest);
156
- for (const { source, destination } of result.assetFiles) {
157
- await copy(source, destination);
158
- }
159
- }
160
- exports.augmentAppWithServiceWorker = augmentAppWithServiceWorker;
161
- // This is currently used by the esbuild-based builder
162
- async function augmentAppWithServiceWorkerEsbuild(workspaceRoot, configPath, baseHref, indexHtml, outputFiles, assetFiles) {
163
- // Read the configuration file
164
- let config;
165
- try {
166
- const configurationData = await node_fs_1.promises.readFile(configPath, 'utf-8');
167
- config = JSON.parse(configurationData);
168
- if (indexHtml) {
169
- config.index = indexHtml;
170
- }
171
- }
172
- catch (error) {
173
- (0, error_1.assertIsError)(error);
174
- if (error.code === 'ENOENT') {
175
- // TODO: Generate an error object that can be consumed by the esbuild-based builder
176
- const message = `Service worker configuration file "${path.relative(workspaceRoot, configPath)}" could not be found.`;
177
- throw new Error(message);
178
- }
179
- else {
180
- throw error;
181
- }
182
- }
183
- return augmentAppWithServiceWorkerCore(config, new ResultFilesystem(outputFiles, assetFiles), baseHref);
184
- }
185
- exports.augmentAppWithServiceWorkerEsbuild = augmentAppWithServiceWorkerEsbuild;
186
- async function augmentAppWithServiceWorkerCore(config, serviceWorkerFilesystem, baseHref) {
187
- // Load ESM `@angular/service-worker/config` using the TypeScript dynamic import workaround.
188
- // Once TypeScript provides support for keeping the dynamic import this workaround can be
189
- // changed to a direct dynamic import.
190
- const GeneratorConstructor = (await (0, load_esm_1.loadEsmModule)('@angular/service-worker/config')).Generator;
191
- // Generate the manifest
192
- const generator = new GeneratorConstructor(serviceWorkerFilesystem, baseHref);
193
- const output = await generator.process(config);
194
- // Write the manifest
195
- const manifest = JSON.stringify(output, null, 2);
196
- // Find the service worker package
197
- const workerPath = require.resolve('@angular/service-worker/ngsw-worker.js');
198
- const result = {
199
- manifest,
200
- // Main worker code
201
- assetFiles: [{ source: workerPath, destination: 'ngsw-worker.js' }],
202
- };
203
- // If present, write the safety worker code
204
- const safetyPath = path.join(path.dirname(workerPath), 'safety-worker.js');
205
- if ((0, node_fs_1.existsSync)(safetyPath)) {
206
- result.assetFiles.push({ source: safetyPath, destination: 'worker-basic.min.js' });
207
- result.assetFiles.push({ source: safetyPath, destination: 'safety-worker.js' });
208
- }
209
- return result;
210
- }
211
- exports.augmentAppWithServiceWorkerCore = augmentAppWithServiceWorkerCore;
@@ -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 { BudgetCalculatorResult } from './bundle-calculator';
9
- export type BundleStatsData = [
10
- files: string,
11
- names: string,
12
- rawSize: number | string,
13
- estimatedTransferSize: number | string
14
- ];
15
- export interface BundleStats {
16
- initial: boolean;
17
- stats: BundleStatsData;
18
- }
19
- export declare function generateEsbuildBuildStatsTable([browserStats, serverStats]: [browserStats: BundleStats[], serverStats: BundleStats[]], colors: boolean, showTotalSize: boolean, showEstimatedTransferSize: boolean, budgetFailures?: BudgetCalculatorResult[], verbose?: boolean): string;
20
- export declare function generateBuildStatsTable(data: BundleStats[], colors: boolean, showTotalSize: boolean, showEstimatedTransferSize: boolean, budgetFailures?: BudgetCalculatorResult[]): string;
@@ -1,205 +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.generateBuildStatsTable = exports.generateEsbuildBuildStatsTable = void 0;
11
- const node_util_1 = require("node:util");
12
- const color_1 = require("./color");
13
- const format_bytes_1 = require("./format-bytes");
14
- function generateEsbuildBuildStatsTable([browserStats, serverStats], colors, showTotalSize, showEstimatedTransferSize, budgetFailures, verbose) {
15
- const bundleInfo = generateBuildStatsData(browserStats, colors, showTotalSize, showEstimatedTransferSize, budgetFailures, verbose);
16
- if (serverStats.length) {
17
- const m = (x) => (colors ? color_1.colors.magenta(x) : x);
18
- if (browserStats.length) {
19
- bundleInfo.unshift([m('Browser bundles')]);
20
- // Add seperators between browser and server logs
21
- bundleInfo.push([], []);
22
- }
23
- bundleInfo.push([m('Server bundles')], ...generateBuildStatsData(serverStats, colors, false, false, undefined, verbose));
24
- }
25
- return generateTableText(bundleInfo, colors);
26
- }
27
- exports.generateEsbuildBuildStatsTable = generateEsbuildBuildStatsTable;
28
- function generateBuildStatsTable(data, colors, showTotalSize, showEstimatedTransferSize, budgetFailures) {
29
- const bundleInfo = generateBuildStatsData(data, colors, showTotalSize, showEstimatedTransferSize, budgetFailures, true);
30
- return generateTableText(bundleInfo, colors);
31
- }
32
- exports.generateBuildStatsTable = generateBuildStatsTable;
33
- function generateBuildStatsData(data, colors, showTotalSize, showEstimatedTransferSize, budgetFailures, verbose) {
34
- if (data.length === 0) {
35
- return [];
36
- }
37
- const g = (x) => (colors ? color_1.colors.green(x) : x);
38
- const c = (x) => (colors ? color_1.colors.cyan(x) : x);
39
- const r = (x) => (colors ? color_1.colors.redBright(x) : x);
40
- const y = (x) => (colors ? color_1.colors.yellowBright(x) : x);
41
- const bold = (x) => (colors ? color_1.colors.bold(x) : x);
42
- const dim = (x) => (colors ? color_1.colors.dim(x) : x);
43
- const getSizeColor = (name, file, defaultColor = c) => {
44
- const severity = budgets.get(name) || (file && budgets.get(file));
45
- switch (severity) {
46
- case 'warning':
47
- return y;
48
- case 'error':
49
- return r;
50
- default:
51
- return defaultColor;
52
- }
53
- };
54
- const changedEntryChunksStats = [];
55
- const changedLazyChunksStats = [];
56
- let initialTotalRawSize = 0;
57
- let changedLazyChunksCount = 0;
58
- let initialTotalEstimatedTransferSize;
59
- const maxLazyChunksWithoutBudgetFailures = 15;
60
- const budgets = new Map();
61
- if (budgetFailures) {
62
- for (const { label, severity } of budgetFailures) {
63
- // In some cases a file can have multiple budget failures.
64
- // Favor error.
65
- if (label && (!budgets.has(label) || budgets.get(label) === 'warning')) {
66
- budgets.set(label, severity);
67
- }
68
- }
69
- }
70
- // Sort descending by raw size
71
- data.sort((a, b) => {
72
- if (a.stats[2] > b.stats[2]) {
73
- return -1;
74
- }
75
- if (a.stats[2] < b.stats[2]) {
76
- return 1;
77
- }
78
- return 0;
79
- });
80
- for (const { initial, stats } of data) {
81
- const [files, names, rawSize, estimatedTransferSize] = stats;
82
- if (!initial &&
83
- !verbose &&
84
- changedLazyChunksStats.length >= maxLazyChunksWithoutBudgetFailures &&
85
- !budgets.has(names) &&
86
- !budgets.has(files)) {
87
- // Limit the number of lazy chunks displayed in the stats table when there is no budget failure and not in verbose mode.
88
- changedLazyChunksCount++;
89
- continue;
90
- }
91
- const getRawSizeColor = getSizeColor(names, files);
92
- let data;
93
- if (showEstimatedTransferSize) {
94
- data = [
95
- g(files),
96
- dim(names),
97
- getRawSizeColor(typeof rawSize === 'number' ? (0, format_bytes_1.formatSize)(rawSize) : rawSize),
98
- c(typeof estimatedTransferSize === 'number'
99
- ? (0, format_bytes_1.formatSize)(estimatedTransferSize)
100
- : estimatedTransferSize),
101
- ];
102
- }
103
- else {
104
- data = [
105
- g(files),
106
- dim(names),
107
- getRawSizeColor(typeof rawSize === 'number' ? (0, format_bytes_1.formatSize)(rawSize) : rawSize),
108
- '',
109
- ];
110
- }
111
- if (initial) {
112
- changedEntryChunksStats.push(data);
113
- if (typeof rawSize === 'number') {
114
- initialTotalRawSize += rawSize;
115
- }
116
- if (showEstimatedTransferSize && typeof estimatedTransferSize === 'number') {
117
- if (initialTotalEstimatedTransferSize === undefined) {
118
- initialTotalEstimatedTransferSize = 0;
119
- }
120
- initialTotalEstimatedTransferSize += estimatedTransferSize;
121
- }
122
- }
123
- else {
124
- changedLazyChunksStats.push(data);
125
- changedLazyChunksCount++;
126
- }
127
- }
128
- const bundleInfo = [];
129
- const baseTitles = ['Names', 'Raw size'];
130
- if (showEstimatedTransferSize) {
131
- baseTitles.push('Estimated transfer size');
132
- }
133
- // Entry chunks
134
- if (changedEntryChunksStats.length) {
135
- bundleInfo.push(['Initial chunk files', ...baseTitles].map(bold), ...changedEntryChunksStats);
136
- if (showTotalSize) {
137
- const initialSizeTotalColor = getSizeColor('bundle initial', undefined, (x) => x);
138
- const totalSizeElements = [
139
- ' ',
140
- 'Initial total',
141
- initialSizeTotalColor((0, format_bytes_1.formatSize)(initialTotalRawSize)),
142
- ];
143
- if (showEstimatedTransferSize) {
144
- totalSizeElements.push(typeof initialTotalEstimatedTransferSize === 'number'
145
- ? (0, format_bytes_1.formatSize)(initialTotalEstimatedTransferSize)
146
- : '-');
147
- }
148
- bundleInfo.push([], totalSizeElements.map(bold));
149
- }
150
- }
151
- // Seperator
152
- if (changedEntryChunksStats.length && changedLazyChunksStats.length) {
153
- bundleInfo.push([]);
154
- }
155
- // Lazy chunks
156
- if (changedLazyChunksStats.length) {
157
- bundleInfo.push(['Lazy chunk files', ...baseTitles].map(bold), ...changedLazyChunksStats);
158
- if (changedLazyChunksCount > changedLazyChunksStats.length) {
159
- bundleInfo.push([
160
- dim(`...and ${changedLazyChunksCount - changedLazyChunksStats.length} more lazy chunks files. ` +
161
- 'Use "--verbose" to show all the files.'),
162
- ]);
163
- }
164
- }
165
- return bundleInfo;
166
- }
167
- function generateTableText(bundleInfo, colors) {
168
- const skipText = (value) => value.includes('...and ');
169
- const longest = [];
170
- for (const item of bundleInfo) {
171
- for (let i = 0; i < item.length; i++) {
172
- if (item[i] === undefined) {
173
- continue;
174
- }
175
- const currentItem = item[i].toString();
176
- if (skipText(currentItem)) {
177
- continue;
178
- }
179
- const currentLongest = (longest[i] ??= 0);
180
- const currentItemLength = (0, node_util_1.stripVTControlCharacters)(currentItem).length;
181
- if (currentLongest < currentItemLength) {
182
- longest[i] = currentItemLength;
183
- }
184
- }
185
- }
186
- const seperator = colors ? color_1.colors.dim(' | ') : ' | ';
187
- const outputTable = [];
188
- for (const item of bundleInfo) {
189
- for (let i = 0; i < longest.length; i++) {
190
- if (item[i] === undefined) {
191
- continue;
192
- }
193
- const currentItem = item[i].toString();
194
- if (skipText(currentItem)) {
195
- continue;
196
- }
197
- const currentItemLength = (0, node_util_1.stripVTControlCharacters)(currentItem).length;
198
- const stringPad = ' '.repeat(longest[i] - currentItemLength);
199
- // Values in columns at index 2 and 3 (Raw and Estimated sizes) are always right aligned.
200
- item[i] = i >= 2 ? stringPad + currentItem : currentItem + stringPad;
201
- }
202
- outputTable.push(item.join(seperator));
203
- }
204
- return outputTable.join('\n');
205
- }
@@ -1,10 +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 function getSupportedBrowsers(projectRoot: string, logger: {
9
- warn(message: string): void;
10
- }): string[];
@@ -1,42 +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.getSupportedBrowsers = void 0;
14
- const browserslist_1 = __importDefault(require("browserslist"));
15
- function getSupportedBrowsers(projectRoot, logger) {
16
- browserslist_1.default.defaults = [
17
- 'last 2 Chrome versions',
18
- 'last 1 Firefox version',
19
- 'last 2 Edge major versions',
20
- 'last 2 Safari major versions',
21
- 'last 2 iOS major versions',
22
- 'Firefox ESR',
23
- ];
24
- // Get browsers from config or default.
25
- const browsersFromConfigOrDefault = new Set((0, browserslist_1.default)(undefined, { path: projectRoot }));
26
- // Get browsers that support ES6 modules.
27
- const browsersThatSupportEs6 = new Set((0, browserslist_1.default)('supports es6-module'));
28
- const unsupportedBrowsers = [];
29
- for (const browser of browsersFromConfigOrDefault) {
30
- if (!browsersThatSupportEs6.has(browser)) {
31
- browsersFromConfigOrDefault.delete(browser);
32
- unsupportedBrowsers.push(browser);
33
- }
34
- }
35
- if (unsupportedBrowsers.length) {
36
- logger.warn(`One or more browsers which are configured in the project's Browserslist configuration ` +
37
- 'will be ignored as ES5 output is not supported by the Angular CLI.\n' +
38
- `Ignored browsers: ${unsupportedBrowsers.join(', ')}`);
39
- }
40
- return Array.from(browsersFromConfigOrDefault);
41
- }
42
- exports.getSupportedBrowsers = getSupportedBrowsers;
@@ -1,8 +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 function assertCompatibleAngularVersion(projectRoot: string): void | never;