@angular/build 18.0.0-next.3

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 (253) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/builders.json +14 -0
  4. package/package.json +87 -0
  5. package/src/builders/application/build-action.d.ts +33 -0
  6. package/src/builders/application/build-action.js +183 -0
  7. package/src/builders/application/execute-build.d.ts +11 -0
  8. package/src/builders/application/execute-build.js +125 -0
  9. package/src/builders/application/execute-post-bundle.d.ts +25 -0
  10. package/src/builders/application/execute-post-bundle.js +93 -0
  11. package/src/builders/application/i18n.d.ts +29 -0
  12. package/src/builders/application/i18n.js +128 -0
  13. package/src/builders/application/index.d.ts +57 -0
  14. package/src/builders/application/index.js +121 -0
  15. package/src/builders/application/options.d.ts +149 -0
  16. package/src/builders/application/options.js +369 -0
  17. package/src/builders/application/schema.d.ts +512 -0
  18. package/src/builders/application/schema.js +58 -0
  19. package/src/builders/application/schema.json +635 -0
  20. package/src/builders/application/setup-bundling.d.ts +19 -0
  21. package/src/builders/application/setup-bundling.js +71 -0
  22. package/src/builders/dev-server/builder.d.ts +32 -0
  23. package/src/builders/dev-server/builder.js +70 -0
  24. package/src/builders/dev-server/index.d.ts +14 -0
  25. package/src/builders/dev-server/index.js +15 -0
  26. package/src/builders/dev-server/internal.d.ts +19 -0
  27. package/src/builders/dev-server/internal.js +29 -0
  28. package/src/builders/dev-server/options.d.ts +47 -0
  29. package/src/builders/dev-server/options.js +65 -0
  30. package/src/builders/dev-server/output.d.ts +16 -0
  31. package/src/builders/dev-server/output.js +9 -0
  32. package/src/builders/dev-server/schema.d.ts +118 -0
  33. package/src/builders/dev-server/schema.js +4 -0
  34. package/src/builders/dev-server/schema.json +131 -0
  35. package/src/builders/dev-server/vite-server.d.ts +31 -0
  36. package/src/builders/dev-server/vite-server.js +504 -0
  37. package/src/index.d.ts +11 -0
  38. package/src/index.js +16 -0
  39. package/src/private.d.ts +35 -0
  40. package/src/private.js +70 -0
  41. package/src/tools/babel/plugins/adjust-static-class-members.d.ts +26 -0
  42. package/src/tools/babel/plugins/adjust-static-class-members.js +351 -0
  43. package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +22 -0
  44. package/src/tools/babel/plugins/adjust-typescript-enums.js +113 -0
  45. package/src/tools/babel/plugins/elide-angular-metadata.d.ts +22 -0
  46. package/src/tools/babel/plugins/elide-angular-metadata.js +110 -0
  47. package/src/tools/babel/plugins/index.d.ts +11 -0
  48. package/src/tools/babel/plugins/index.js +21 -0
  49. package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +15 -0
  50. package/src/tools/babel/plugins/pure-toplevel-functions.js +90 -0
  51. package/src/tools/babel/typings.d.ts +21 -0
  52. package/src/tools/esbuild/angular/angular-host.d.ts +26 -0
  53. package/src/tools/esbuild/angular/angular-host.js +134 -0
  54. package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +42 -0
  55. package/src/tools/esbuild/angular/compilation/angular-compilation.js +94 -0
  56. package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +21 -0
  57. package/src/tools/esbuild/angular/compilation/aot-compilation.js +224 -0
  58. package/src/tools/esbuild/angular/compilation/factory.d.ts +16 -0
  59. package/src/tools/esbuild/angular/compilation/factory.js +56 -0
  60. package/src/tools/esbuild/angular/compilation/index.d.ts +10 -0
  61. package/src/tools/esbuild/angular/compilation/index.js +17 -0
  62. package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.d.ts +10 -0
  63. package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.js +182 -0
  64. package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +21 -0
  65. package/src/tools/esbuild/angular/compilation/jit-compilation.js +106 -0
  66. package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +20 -0
  67. package/src/tools/esbuild/angular/compilation/noop-compilation.js +26 -0
  68. package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +42 -0
  69. package/src/tools/esbuild/angular/compilation/parallel-compilation.js +123 -0
  70. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +33 -0
  71. package/src/tools/esbuild/angular/compilation/parallel-worker.js +90 -0
  72. package/src/tools/esbuild/angular/compilation-state.d.ts +15 -0
  73. package/src/tools/esbuild/angular/compilation-state.js +44 -0
  74. package/src/tools/esbuild/angular/compiler-plugin.d.ts +27 -0
  75. package/src/tools/esbuild/angular/compiler-plugin.js +441 -0
  76. package/src/tools/esbuild/angular/component-stylesheets.d.ts +44 -0
  77. package/src/tools/esbuild/angular/component-stylesheets.js +150 -0
  78. package/src/tools/esbuild/angular/diagnostics.d.ts +15 -0
  79. package/src/tools/esbuild/angular/diagnostics.js +69 -0
  80. package/src/tools/esbuild/angular/file-reference-tracker.d.ts +17 -0
  81. package/src/tools/esbuild/angular/file-reference-tracker.js +57 -0
  82. package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +23 -0
  83. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +117 -0
  84. package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +17 -0
  85. package/src/tools/esbuild/angular/jit-resource-transformer.js +186 -0
  86. package/src/tools/esbuild/angular/source-file-cache.d.ts +18 -0
  87. package/src/tools/esbuild/angular/source-file-cache.js +65 -0
  88. package/src/tools/esbuild/angular/uri.d.ts +54 -0
  89. package/src/tools/esbuild/angular/uri.js +74 -0
  90. package/src/tools/esbuild/angular/web-worker-transformer.d.ts +17 -0
  91. package/src/tools/esbuild/angular/web-worker-transformer.js +94 -0
  92. package/src/tools/esbuild/application-code-bundle.d.ts +20 -0
  93. package/src/tools/esbuild/application-code-bundle.js +368 -0
  94. package/src/tools/esbuild/budget-stats.d.ts +19 -0
  95. package/src/tools/esbuild/budget-stats.js +59 -0
  96. package/src/tools/esbuild/bundler-context.d.ts +75 -0
  97. package/src/tools/esbuild/bundler-context.js +366 -0
  98. package/src/tools/esbuild/bundler-execution-result.d.ts +71 -0
  99. package/src/tools/esbuild/bundler-execution-result.js +131 -0
  100. package/src/tools/esbuild/cache.d.ts +88 -0
  101. package/src/tools/esbuild/cache.js +92 -0
  102. package/src/tools/esbuild/commonjs-checker.d.ts +28 -0
  103. package/src/tools/esbuild/commonjs-checker.js +151 -0
  104. package/src/tools/esbuild/compiler-plugin-options.d.ts +16 -0
  105. package/src/tools/esbuild/compiler-plugin-options.js +49 -0
  106. package/src/tools/esbuild/external-packages-plugin.d.ts +18 -0
  107. package/src/tools/esbuild/external-packages-plugin.js +70 -0
  108. package/src/tools/esbuild/global-scripts.d.ts +16 -0
  109. package/src/tools/esbuild/global-scripts.js +142 -0
  110. package/src/tools/esbuild/global-styles.d.ts +10 -0
  111. package/src/tools/esbuild/global-styles.js +74 -0
  112. package/src/tools/esbuild/i18n-inliner-worker.d.ts +42 -0
  113. package/src/tools/esbuild/i18n-inliner-worker.js +136 -0
  114. package/src/tools/esbuild/i18n-inliner.d.ts +44 -0
  115. package/src/tools/esbuild/i18n-inliner.js +150 -0
  116. package/src/tools/esbuild/i18n-locale-plugin.d.ts +22 -0
  117. package/src/tools/esbuild/i18n-locale-plugin.js +120 -0
  118. package/src/tools/esbuild/index-html-generator.d.ts +15 -0
  119. package/src/tools/esbuild/index-html-generator.js +81 -0
  120. package/src/tools/esbuild/javascript-transformer-worker.d.ts +19 -0
  121. package/src/tools/esbuild/javascript-transformer-worker.js +154 -0
  122. package/src/tools/esbuild/javascript-transformer.d.ts +54 -0
  123. package/src/tools/esbuild/javascript-transformer.js +147 -0
  124. package/src/tools/esbuild/license-extractor.d.ts +25 -0
  125. package/src/tools/esbuild/license-extractor.js +158 -0
  126. package/src/tools/esbuild/load-result-cache.d.ts +21 -0
  127. package/src/tools/esbuild/load-result-cache.js +75 -0
  128. package/src/tools/esbuild/profiling.d.ts +11 -0
  129. package/src/tools/esbuild/profiling.js +78 -0
  130. package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +18 -0
  131. package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +44 -0
  132. package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +17 -0
  133. package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +73 -0
  134. package/src/tools/esbuild/stylesheets/bundle-options.d.ts +35 -0
  135. package/src/tools/esbuild/stylesheets/bundle-options.js +64 -0
  136. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +25 -0
  137. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +57 -0
  138. package/src/tools/esbuild/stylesheets/css-language.d.ts +9 -0
  139. package/src/tools/esbuild/stylesheets/css-language.js +15 -0
  140. package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +18 -0
  141. package/src/tools/esbuild/stylesheets/css-resource-plugin.js +114 -0
  142. package/src/tools/esbuild/stylesheets/less-language.d.ts +9 -0
  143. package/src/tools/esbuild/stylesheets/less-language.js +155 -0
  144. package/src/tools/esbuild/stylesheets/sass-language.d.ts +10 -0
  145. package/src/tools/esbuild/stylesheets/sass-language.js +185 -0
  146. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +58 -0
  147. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +282 -0
  148. package/src/tools/esbuild/utils.d.ts +49 -0
  149. package/src/tools/esbuild/utils.js +392 -0
  150. package/src/tools/esbuild/virtual-module-plugin.d.ts +33 -0
  151. package/src/tools/esbuild/virtual-module-plugin.js +43 -0
  152. package/src/tools/esbuild/watcher.d.ts +25 -0
  153. package/src/tools/esbuild/watcher.js +118 -0
  154. package/src/tools/sass/lexer.d.ts +18 -0
  155. package/src/tools/sass/lexer.js +161 -0
  156. package/src/tools/sass/rebasing-importer.d.ts +101 -0
  157. package/src/tools/sass/rebasing-importer.js +334 -0
  158. package/src/tools/sass/sass-service.d.ts +72 -0
  159. package/src/tools/sass/sass-service.js +213 -0
  160. package/src/tools/sass/worker.d.ts +8 -0
  161. package/src/tools/sass/worker.js +192 -0
  162. package/src/tools/vite/angular-memory-plugin.d.ts +24 -0
  163. package/src/tools/vite/angular-memory-plugin.js +268 -0
  164. package/src/tools/vite/i18n-locale-plugin.d.ts +18 -0
  165. package/src/tools/vite/i18n-locale-plugin.js +55 -0
  166. package/src/utils/bundle-calculator.d.ts +44 -0
  167. package/src/utils/bundle-calculator.js +303 -0
  168. package/src/utils/check-port.d.ts +8 -0
  169. package/src/utils/check-port.js +58 -0
  170. package/src/utils/color.d.ts +10 -0
  171. package/src/utils/color.js +63 -0
  172. package/src/utils/delete-output-dir.d.ts +11 -0
  173. package/src/utils/delete-output-dir.js +46 -0
  174. package/src/utils/environment-options.d.ts +16 -0
  175. package/src/utils/environment-options.js +79 -0
  176. package/src/utils/error.d.ts +10 -0
  177. package/src/utils/error.js +21 -0
  178. package/src/utils/format-bytes.d.ts +8 -0
  179. package/src/utils/format-bytes.js +22 -0
  180. package/src/utils/i18n-options.d.ts +33 -0
  181. package/src/utils/i18n-options.js +161 -0
  182. package/src/utils/index-file/add-event-dispatch-contract.d.ts +8 -0
  183. package/src/utils/index-file/add-event-dispatch-contract.js +28 -0
  184. package/src/utils/index-file/augment-index-html.d.ts +40 -0
  185. package/src/utils/index-file/augment-index-html.js +239 -0
  186. package/src/utils/index-file/html-rewriting-stream.d.ts +11 -0
  187. package/src/utils/index-file/html-rewriting-stream.js +28 -0
  188. package/src/utils/index-file/index-html-generator.d.ts +57 -0
  189. package/src/utils/index-file/index-html-generator.js +135 -0
  190. package/src/utils/index-file/inline-critical-css.d.ts +24 -0
  191. package/src/utils/index-file/inline-critical-css.js +179 -0
  192. package/src/utils/index-file/inline-fonts.d.ts +23 -0
  193. package/src/utils/index-file/inline-fonts.js +267 -0
  194. package/src/utils/index-file/nonce.d.ts +12 -0
  195. package/src/utils/index-file/nonce.js +55 -0
  196. package/src/utils/index-file/style-nonce.d.ts +12 -0
  197. package/src/utils/index-file/style-nonce.js +55 -0
  198. package/src/utils/index.d.ts +11 -0
  199. package/src/utils/index.js +27 -0
  200. package/src/utils/load-esm.d.ts +20 -0
  201. package/src/utils/load-esm.js +31 -0
  202. package/src/utils/load-proxy-config.d.ts +8 -0
  203. package/src/utils/load-proxy-config.js +189 -0
  204. package/src/utils/load-translations.d.ts +16 -0
  205. package/src/utils/load-translations.js +84 -0
  206. package/src/utils/normalize-asset-patterns.d.ts +14 -0
  207. package/src/utils/normalize-asset-patterns.js +96 -0
  208. package/src/utils/normalize-cache.d.ts +16 -0
  209. package/src/utils/normalize-cache.js +44 -0
  210. package/src/utils/normalize-optimization.d.ts +13 -0
  211. package/src/utils/normalize-optimization.js +42 -0
  212. package/src/utils/normalize-source-maps.d.ts +9 -0
  213. package/src/utils/normalize-source-maps.js +23 -0
  214. package/src/utils/postcss-configuration.d.ts +17 -0
  215. package/src/utils/postcss-configuration.js +86 -0
  216. package/src/utils/purge-cache.d.ts +10 -0
  217. package/src/utils/purge-cache.js +40 -0
  218. package/src/utils/resolve-assets.d.ts +18 -0
  219. package/src/utils/resolve-assets.js +35 -0
  220. package/src/utils/routes-extractor/extractor.d.ts +15 -0
  221. package/src/utils/routes-extractor/extractor.js +97 -0
  222. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +18 -0
  223. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +129 -0
  224. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +8 -0
  225. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +13 -0
  226. package/src/utils/server-rendering/fetch-patch.d.ts +8 -0
  227. package/src/utils/server-rendering/fetch-patch.js +66 -0
  228. package/src/utils/server-rendering/load-esm-from-memory.d.ts +10 -0
  229. package/src/utils/server-rendering/load-esm-from-memory.js +26 -0
  230. package/src/utils/server-rendering/main-bundle-exports.d.ts +27 -0
  231. package/src/utils/server-rendering/main-bundle-exports.js +9 -0
  232. package/src/utils/server-rendering/prerender.d.ts +23 -0
  233. package/src/utils/server-rendering/prerender.js +192 -0
  234. package/src/utils/server-rendering/render-page.d.ts +26 -0
  235. package/src/utils/server-rendering/render-page.js +110 -0
  236. package/src/utils/server-rendering/render-worker.d.ts +22 -0
  237. package/src/utils/server-rendering/render-worker.js +30 -0
  238. package/src/utils/server-rendering/routes-extractor-worker.d.ts +21 -0
  239. package/src/utils/server-rendering/routes-extractor-worker.js +53 -0
  240. package/src/utils/service-worker.d.ts +25 -0
  241. package/src/utils/service-worker.js +211 -0
  242. package/src/utils/spinner.d.ts +20 -0
  243. package/src/utils/spinner.js +55 -0
  244. package/src/utils/stats-table.d.ts +20 -0
  245. package/src/utils/stats-table.js +205 -0
  246. package/src/utils/supported-browsers.d.ts +10 -0
  247. package/src/utils/supported-browsers.js +42 -0
  248. package/src/utils/tty.d.ts +8 -0
  249. package/src/utils/tty.js +23 -0
  250. package/src/utils/url.d.ts +8 -0
  251. package/src/utils/url.js +18 -0
  252. package/src/utils/version.d.ts +8 -0
  253. package/src/utils/version.js +59 -0
@@ -0,0 +1,211 @@
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;
@@ -0,0 +1,20 @@
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 Spinner {
9
+ #private;
10
+ private readonly spinner;
11
+ /** When false, only fail messages will be displayed. */
12
+ enabled: boolean;
13
+ constructor(text?: string);
14
+ set text(text: string);
15
+ get isSpinning(): boolean;
16
+ succeed(text?: string): void;
17
+ fail(text?: string): void;
18
+ stop(): void;
19
+ start(text?: string): void;
20
+ }
@@ -0,0 +1,55 @@
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.Spinner = void 0;
14
+ const ora_1 = __importDefault(require("ora"));
15
+ const color_1 = require("./color");
16
+ const tty_1 = require("./tty");
17
+ class Spinner {
18
+ spinner;
19
+ /** When false, only fail messages will be displayed. */
20
+ enabled = true;
21
+ #isTTY = (0, tty_1.isTTY)();
22
+ constructor(text) {
23
+ this.spinner = (0, ora_1.default)({
24
+ text: text === undefined ? undefined : text + '\n',
25
+ // The below 2 options are needed because otherwise CTRL+C will be delayed
26
+ // when the underlying process is sync.
27
+ hideCursor: false,
28
+ discardStdin: false,
29
+ isEnabled: this.#isTTY,
30
+ });
31
+ }
32
+ set text(text) {
33
+ this.spinner.text = text;
34
+ }
35
+ get isSpinning() {
36
+ return this.spinner.isSpinning || !this.#isTTY;
37
+ }
38
+ succeed(text) {
39
+ if (this.enabled) {
40
+ this.spinner.succeed(text);
41
+ }
42
+ }
43
+ fail(text) {
44
+ this.spinner.fail(text && color_1.colors.redBright(text));
45
+ }
46
+ stop() {
47
+ this.spinner.stop();
48
+ }
49
+ start(text) {
50
+ if (this.enabled) {
51
+ this.spinner.start(text);
52
+ }
53
+ }
54
+ }
55
+ exports.Spinner = Spinner;
@@ -0,0 +1,20 @@
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;
@@ -0,0 +1,205 @@
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
+ }
@@ -0,0 +1,10 @@
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[];
@@ -0,0 +1,42 @@
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;
@@ -0,0 +1,8 @@
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 isTTY(): boolean;
@@ -0,0 +1,23 @@
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.isTTY = void 0;
11
+ function _isTruthy(value) {
12
+ // Returns true if value is a string that is anything but 0 or false.
13
+ return value !== undefined && value !== '0' && value.toUpperCase() !== 'FALSE';
14
+ }
15
+ function isTTY() {
16
+ // If we force TTY, we always return true.
17
+ const force = process.env['NG_FORCE_TTY'];
18
+ if (force !== undefined) {
19
+ return _isTruthy(force);
20
+ }
21
+ return !!process.stdout.isTTY && !_isTruthy(process.env['CI']);
22
+ }
23
+ exports.isTTY = isTTY;
@@ -0,0 +1,8 @@
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 urlJoin(...parts: string[]): string;
@@ -0,0 +1,18 @@
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.urlJoin = void 0;
11
+ function urlJoin(...parts) {
12
+ const [p, ...rest] = parts;
13
+ // Remove trailing slash from first part
14
+ // Join all parts with `/`
15
+ // Dedupe double slashes from path names
16
+ return p.replace(/\/$/, '') + ('/' + rest.join('/')).replace(/\/\/+/g, '/');
17
+ }
18
+ exports.urlJoin = urlJoin;
@@ -0,0 +1,8 @@
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;