@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,378 +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.logMessages = exports.createJsonBuildManifest = exports.getSupportedNodeTargets = exports.transformSupportedBrowsersToTargets = exports.convertOutputFile = exports.createOutputFileFromData = exports.createOutputFileFromText = exports.emitFilesToDisk = exports.writeResultFiles = exports.getFeatureSupport = exports.withNoProgress = exports.withSpinner = exports.calculateEstimatedTransferSizes = exports.logBuildStats = void 0;
14
- const esbuild_1 = require("esbuild");
15
- const node_crypto_1 = require("node:crypto");
16
- const node_fs_1 = require("node:fs");
17
- const promises_1 = __importDefault(require("node:fs/promises"));
18
- const node_path_1 = require("node:path");
19
- const node_url_1 = require("node:url");
20
- const node_zlib_1 = require("node:zlib");
21
- const semver_1 = require("semver");
22
- const spinner_1 = require("../../utils/spinner");
23
- const stats_table_1 = require("../../utils/stats-table");
24
- const bundler_context_1 = require("./bundler-context");
25
- function logBuildStats(metafile, initial, budgetFailures, colors, changedFiles, estimatedTransferSizes, ssrOutputEnabled, verbose) {
26
- const browserStats = [];
27
- const serverStats = [];
28
- let unchangedCount = 0;
29
- for (const [file, output] of Object.entries(metafile.outputs)) {
30
- // Only display JavaScript and CSS files
31
- if (!/\.(?:css|m?js)$/.test(file)) {
32
- continue;
33
- }
34
- // Skip internal component resources
35
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- if (output['ng-component']) {
37
- continue;
38
- }
39
- // Show only changed files if a changed list is provided
40
- if (changedFiles && !changedFiles.has(file)) {
41
- ++unchangedCount;
42
- continue;
43
- }
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- const isPlatformServer = output['ng-platform-server'];
46
- if (isPlatformServer && !ssrOutputEnabled) {
47
- // Only log server build stats when SSR is enabled.
48
- continue;
49
- }
50
- let name = initial.get(file)?.name;
51
- if (name === undefined && output.entryPoint) {
52
- name = (0, node_path_1.basename)(output.entryPoint)
53
- .replace(/\.[cm]?[jt]s$/, '')
54
- .replace(/[\\/.]/g, '-');
55
- }
56
- const stat = {
57
- initial: initial.has(file),
58
- stats: [file, name ?? '-', output.bytes, estimatedTransferSizes?.get(file) ?? '-'],
59
- };
60
- if (isPlatformServer) {
61
- serverStats.push(stat);
62
- }
63
- else {
64
- browserStats.push(stat);
65
- }
66
- }
67
- if (browserStats.length > 0 || serverStats.length > 0) {
68
- const tableText = (0, stats_table_1.generateEsbuildBuildStatsTable)([browserStats, serverStats], colors, unchangedCount === 0, !!estimatedTransferSizes, budgetFailures, verbose);
69
- return tableText + '\n';
70
- }
71
- else if (changedFiles !== undefined) {
72
- return '\nNo output file changes.\n';
73
- }
74
- if (unchangedCount > 0) {
75
- return `Unchanged output files: ${unchangedCount}`;
76
- }
77
- return '';
78
- }
79
- exports.logBuildStats = logBuildStats;
80
- async function calculateEstimatedTransferSizes(outputFiles) {
81
- const sizes = new Map();
82
- if (outputFiles.length <= 0) {
83
- return sizes;
84
- }
85
- return new Promise((resolve, reject) => {
86
- let completeCount = 0;
87
- for (const outputFile of outputFiles) {
88
- // Only calculate JavaScript and CSS files
89
- if (!outputFile.path.endsWith('.js') && !outputFile.path.endsWith('.css')) {
90
- ++completeCount;
91
- continue;
92
- }
93
- // Skip compressing small files which may end being larger once compressed and will most likely not be
94
- // compressed in actual transit.
95
- if (outputFile.contents.byteLength < 1024) {
96
- sizes.set(outputFile.path, outputFile.contents.byteLength);
97
- ++completeCount;
98
- continue;
99
- }
100
- // Directly use the async callback function to minimize the number of Promises that need to be created.
101
- (0, node_zlib_1.brotliCompress)(outputFile.contents, (error, result) => {
102
- if (error) {
103
- reject(error);
104
- return;
105
- }
106
- sizes.set(outputFile.path, result.byteLength);
107
- if (++completeCount >= outputFiles.length) {
108
- resolve(sizes);
109
- }
110
- });
111
- }
112
- // Covers the case where no files need to be compressed
113
- if (completeCount >= outputFiles.length) {
114
- resolve(sizes);
115
- }
116
- });
117
- }
118
- exports.calculateEstimatedTransferSizes = calculateEstimatedTransferSizes;
119
- async function withSpinner(text, action) {
120
- const spinner = new spinner_1.Spinner(text);
121
- spinner.start();
122
- try {
123
- return await action();
124
- }
125
- finally {
126
- spinner.stop();
127
- }
128
- }
129
- exports.withSpinner = withSpinner;
130
- async function withNoProgress(text, action) {
131
- return action();
132
- }
133
- exports.withNoProgress = withNoProgress;
134
- /**
135
- * Generates a syntax feature object map for Angular applications based on a list of targets.
136
- * A full set of feature names can be found here: https://esbuild.github.io/api/#supported
137
- * @param target An array of browser/engine targets in the format accepted by the esbuild `target` option.
138
- * @returns An object that can be used with the esbuild build `supported` option.
139
- */
140
- function getFeatureSupport(target) {
141
- const supported = {
142
- // Native async/await is not supported with Zone.js. Disabling support here will cause
143
- // esbuild to downlevel async/await, async generators, and for await...of to a Zone.js supported form.
144
- 'async-await': false,
145
- // V8 currently has a performance defect involving object spread operations that can cause signficant
146
- // degradation in runtime performance. By not supporting the language feature here, a downlevel form
147
- // will be used instead which provides a workaround for the performance issue.
148
- // For more details: https://bugs.chromium.org/p/v8/issues/detail?id=11536
149
- 'object-rest-spread': false,
150
- };
151
- // Detect Safari browser versions that have a class field behavior bug
152
- // See: https://github.com/angular/angular-cli/issues/24355#issuecomment-1333477033
153
- // See: https://github.com/WebKit/WebKit/commit/e8788a34b3d5f5b4edd7ff6450b80936bff396f2
154
- let safariClassFieldScopeBug = false;
155
- for (const browser of target) {
156
- let majorVersion;
157
- if (browser.startsWith('ios')) {
158
- majorVersion = Number(browser.slice(3, 5));
159
- }
160
- else if (browser.startsWith('safari')) {
161
- majorVersion = Number(browser.slice(6, 8));
162
- }
163
- else {
164
- continue;
165
- }
166
- // Technically, 14.0 is not broken but rather does not have support. However, the behavior
167
- // is identical since it would be set to false by esbuild if present as a target.
168
- if (majorVersion === 14 || majorVersion === 15) {
169
- safariClassFieldScopeBug = true;
170
- break;
171
- }
172
- }
173
- // If class field support cannot be used set to false; otherwise leave undefined to allow
174
- // esbuild to use `target` to determine support.
175
- if (safariClassFieldScopeBug) {
176
- supported['class-field'] = false;
177
- supported['class-static-field'] = false;
178
- }
179
- return supported;
180
- }
181
- exports.getFeatureSupport = getFeatureSupport;
182
- async function writeResultFiles(outputFiles, assetFiles, { base, browser, server }) {
183
- const directoryExists = new Set();
184
- const ensureDirectoryExists = async (destPath) => {
185
- const basePath = (0, node_path_1.dirname)(destPath);
186
- if (!directoryExists.has(basePath)) {
187
- await promises_1.default.mkdir((0, node_path_1.join)(base, basePath), { recursive: true });
188
- directoryExists.add(basePath);
189
- }
190
- };
191
- // Writes the output file to disk and ensures the containing directories are present
192
- await emitFilesToDisk(outputFiles, async (file) => {
193
- let outputDir;
194
- switch (file.type) {
195
- case bundler_context_1.BuildOutputFileType.Browser:
196
- case bundler_context_1.BuildOutputFileType.Media:
197
- outputDir = browser;
198
- break;
199
- case bundler_context_1.BuildOutputFileType.Server:
200
- outputDir = server;
201
- break;
202
- case bundler_context_1.BuildOutputFileType.Root:
203
- outputDir = '';
204
- break;
205
- default:
206
- throw new Error(`Unhandled write for file "${file.path}" with type "${bundler_context_1.BuildOutputFileType[file.type]}".`);
207
- }
208
- const destPath = (0, node_path_1.join)(outputDir, file.path);
209
- // Ensure output subdirectories exist
210
- await ensureDirectoryExists(destPath);
211
- // Write file contents
212
- await promises_1.default.writeFile((0, node_path_1.join)(base, destPath), file.contents);
213
- });
214
- if (assetFiles?.length) {
215
- await emitFilesToDisk(assetFiles, async ({ source, destination }) => {
216
- const destPath = (0, node_path_1.join)(browser, destination);
217
- // Ensure output subdirectories exist
218
- await ensureDirectoryExists(destPath);
219
- // Copy file contents
220
- await promises_1.default.copyFile(source, (0, node_path_1.join)(base, destPath), node_fs_1.constants.COPYFILE_FICLONE);
221
- });
222
- }
223
- }
224
- exports.writeResultFiles = writeResultFiles;
225
- const MAX_CONCURRENT_WRITES = 64;
226
- async function emitFilesToDisk(files, writeFileCallback) {
227
- // Write files in groups of MAX_CONCURRENT_WRITES to avoid too many open files
228
- for (let fileIndex = 0; fileIndex < files.length;) {
229
- const groupMax = Math.min(fileIndex + MAX_CONCURRENT_WRITES, files.length);
230
- const actions = [];
231
- while (fileIndex < groupMax) {
232
- actions.push(writeFileCallback(files[fileIndex++]));
233
- }
234
- await Promise.all(actions);
235
- }
236
- }
237
- exports.emitFilesToDisk = emitFilesToDisk;
238
- function createOutputFileFromText(path, text, type) {
239
- return {
240
- path,
241
- text,
242
- type,
243
- get hash() {
244
- return (0, node_crypto_1.createHash)('sha256').update(this.text).digest('hex');
245
- },
246
- get contents() {
247
- return Buffer.from(this.text, 'utf-8');
248
- },
249
- clone() {
250
- return createOutputFileFromText(this.path, this.text, this.type);
251
- },
252
- };
253
- }
254
- exports.createOutputFileFromText = createOutputFileFromText;
255
- function createOutputFileFromData(path, data, type) {
256
- return {
257
- path,
258
- type,
259
- get text() {
260
- return Buffer.from(data.buffer, data.byteOffset, data.byteLength).toString('utf-8');
261
- },
262
- get hash() {
263
- return (0, node_crypto_1.createHash)('sha256').update(this.text).digest('hex');
264
- },
265
- get contents() {
266
- return data;
267
- },
268
- clone() {
269
- return createOutputFileFromData(this.path, this.contents, this.type);
270
- },
271
- };
272
- }
273
- exports.createOutputFileFromData = createOutputFileFromData;
274
- function convertOutputFile(file, type) {
275
- const { path, contents, hash } = file;
276
- return {
277
- contents,
278
- hash,
279
- path,
280
- type,
281
- get text() {
282
- return Buffer.from(this.contents.buffer, this.contents.byteOffset, this.contents.byteLength).toString('utf-8');
283
- },
284
- clone() {
285
- return convertOutputFile(this, this.type);
286
- },
287
- };
288
- }
289
- exports.convertOutputFile = convertOutputFile;
290
- /**
291
- * Transform browserlists result to esbuild target.
292
- * @see https://esbuild.github.io/api/#target
293
- */
294
- function transformSupportedBrowsersToTargets(supportedBrowsers) {
295
- const transformed = [];
296
- // https://esbuild.github.io/api/#target
297
- const esBuildSupportedBrowsers = new Set([
298
- 'chrome',
299
- 'edge',
300
- 'firefox',
301
- 'ie',
302
- 'ios',
303
- 'node',
304
- 'opera',
305
- 'safari',
306
- ]);
307
- for (const browser of supportedBrowsers) {
308
- let [browserName, version] = browser.toLowerCase().split(' ');
309
- // browserslist uses the name `ios_saf` for iOS Safari whereas esbuild uses `ios`
310
- if (browserName === 'ios_saf') {
311
- browserName = 'ios';
312
- }
313
- // browserslist uses ranges `15.2-15.3` versions but only the lowest is required
314
- // to perform minimum supported feature checks. esbuild also expects a single version.
315
- [version] = version.split('-');
316
- if (esBuildSupportedBrowsers.has(browserName)) {
317
- if (browserName === 'safari' && version === 'tp') {
318
- // esbuild only supports numeric versions so `TP` is converted to a high number (999) since
319
- // a Technology Preview (TP) of Safari is assumed to support all currently known features.
320
- version = '999';
321
- }
322
- else if (!version.includes('.')) {
323
- // A lone major version is considered by esbuild to include all minor versions. However,
324
- // browserslist does not and is also inconsistent in its `.0` version naming. For example,
325
- // Safari 15.0 is named `safari 15` but Safari 16.0 is named `safari 16.0`.
326
- version += '.0';
327
- }
328
- transformed.push(browserName + version);
329
- }
330
- }
331
- return transformed;
332
- }
333
- exports.transformSupportedBrowsersToTargets = transformSupportedBrowsersToTargets;
334
- const SUPPORTED_NODE_VERSIONS = '^18.19.1 || >=20.11.1';
335
- /**
336
- * Transform supported Node.js versions to esbuild target.
337
- * @see https://esbuild.github.io/api/#target
338
- */
339
- function getSupportedNodeTargets() {
340
- if (SUPPORTED_NODE_VERSIONS.charAt(0) === '0') {
341
- // Unlike `pkg_npm`, `ts_library` which is used to run unit tests does not support substitutions.
342
- return [];
343
- }
344
- return SUPPORTED_NODE_VERSIONS.split('||').map((v) => 'node' + (0, semver_1.coerce)(v)?.version);
345
- }
346
- exports.getSupportedNodeTargets = getSupportedNodeTargets;
347
- async function createJsonBuildManifest(result, normalizedOptions) {
348
- const { colors: color, outputOptions: { base, server, browser }, ssrOptions, } = normalizedOptions;
349
- const { warnings, errors, prerenderedRoutes } = result;
350
- const manifest = {
351
- errors: errors.length ? await (0, esbuild_1.formatMessages)(errors, { kind: 'error', color }) : [],
352
- warnings: warnings.length ? await (0, esbuild_1.formatMessages)(warnings, { kind: 'warning', color }) : [],
353
- outputPaths: {
354
- root: (0, node_url_1.pathToFileURL)(base),
355
- browser: (0, node_url_1.pathToFileURL)((0, node_path_1.join)(base, browser)),
356
- server: ssrOptions ? (0, node_url_1.pathToFileURL)((0, node_path_1.join)(base, server)) : undefined,
357
- },
358
- prerenderedRoutes,
359
- };
360
- return JSON.stringify(manifest, undefined, 2);
361
- }
362
- exports.createJsonBuildManifest = createJsonBuildManifest;
363
- async function logMessages(logger, executionResult, color, jsonLogs) {
364
- const { warnings, errors, logs } = executionResult;
365
- if (logs.length) {
366
- logger.info(logs.join('\n'));
367
- }
368
- if (jsonLogs) {
369
- return;
370
- }
371
- if (warnings.length) {
372
- logger.warn((await (0, esbuild_1.formatMessages)(warnings, { kind: 'warning', color })).join('\n'));
373
- }
374
- if (errors.length) {
375
- logger.error((await (0, esbuild_1.formatMessages)(errors, { kind: 'error', color })).join('\n'));
376
- }
377
- }
378
- exports.logMessages = logMessages;
@@ -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
- import type { OnLoadArgs, Plugin, PluginBuild } from 'esbuild';
9
- import { LoadResultCache } from './load-result-cache';
10
- /**
11
- * Options for the createVirtualModulePlugin
12
- * @see createVirtualModulePlugin
13
- */
14
- export interface VirtualModulePluginOptions {
15
- /** Namespace. Example: `angular:polyfills`. */
16
- namespace: string;
17
- /** If the generated module should be marked as external. */
18
- external?: boolean;
19
- /** Method to transform the onResolve path. */
20
- transformPath?: (path: string) => string;
21
- /** Method to provide the module content. */
22
- loadContent: (args: OnLoadArgs, build: PluginBuild) => ReturnType<Parameters<PluginBuild['onLoad']>[1]>;
23
- /** Restrict to only entry points. Defaults to `true`. */
24
- entryPointOnly?: boolean;
25
- /** Load results cache. */
26
- cache?: LoadResultCache;
27
- }
28
- /**
29
- * Creates an esbuild plugin that generated virtual modules.
30
- *
31
- * @returns An esbuild plugin.
32
- */
33
- export declare function createVirtualModulePlugin(options: VirtualModulePluginOptions): Plugin;
@@ -1,43 +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.createVirtualModulePlugin = void 0;
11
- const load_result_cache_1 = require("./load-result-cache");
12
- /**
13
- * Creates an esbuild plugin that generated virtual modules.
14
- *
15
- * @returns An esbuild plugin.
16
- */
17
- function createVirtualModulePlugin(options) {
18
- const { namespace, external, transformPath: pathTransformer, loadContent, cache, entryPointOnly = true, } = options;
19
- return {
20
- name: namespace.replace(/[/:]/g, '-'),
21
- setup(build) {
22
- build.onResolve({ filter: new RegExp('^' + namespace) }, ({ kind, path }) => {
23
- if (entryPointOnly && kind !== 'entry-point') {
24
- return null;
25
- }
26
- return {
27
- path: pathTransformer?.(path) ?? path,
28
- namespace,
29
- };
30
- });
31
- if (external) {
32
- build.onResolve({ filter: /./, namespace }, ({ path }) => {
33
- return {
34
- path,
35
- external: true,
36
- };
37
- });
38
- }
39
- build.onLoad({ filter: /./, namespace }, (0, load_result_cache_1.createCachedLoad)(cache, (args) => loadContent(args, build)));
40
- },
41
- };
42
- }
43
- exports.createVirtualModulePlugin = createVirtualModulePlugin;
@@ -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
- export declare class ChangedFiles {
9
- readonly added: Set<string>;
10
- readonly modified: Set<string>;
11
- readonly removed: Set<string>;
12
- get all(): string[];
13
- toDebugString(): string;
14
- }
15
- export interface BuildWatcher extends AsyncIterableIterator<ChangedFiles> {
16
- add(paths: string | readonly string[]): void;
17
- remove(paths: string | readonly string[]): void;
18
- close(): Promise<void>;
19
- }
20
- export declare function createWatcher(options?: {
21
- polling?: boolean;
22
- interval?: number;
23
- ignored?: string[];
24
- followSymlinks?: boolean;
25
- }): BuildWatcher;
@@ -1,118 +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.createWatcher = exports.ChangedFiles = void 0;
14
- const watchpack_1 = __importDefault(require("watchpack"));
15
- class ChangedFiles {
16
- added = new Set();
17
- modified = new Set();
18
- removed = new Set();
19
- get all() {
20
- return [...this.added, ...this.modified, ...this.removed];
21
- }
22
- toDebugString() {
23
- const content = {
24
- added: Array.from(this.added),
25
- modified: Array.from(this.modified),
26
- removed: Array.from(this.removed),
27
- };
28
- return JSON.stringify(content, null, 2);
29
- }
30
- }
31
- exports.ChangedFiles = ChangedFiles;
32
- function createWatcher(options) {
33
- const watcher = new watchpack_1.default({
34
- poll: options?.polling ? options?.interval ?? true : false,
35
- ignored: options?.ignored,
36
- followSymlinks: options?.followSymlinks,
37
- aggregateTimeout: 250,
38
- });
39
- const watchedFiles = new Set();
40
- const nextQueue = [];
41
- let currentChangedFiles;
42
- watcher.on('aggregated', (changes, removals) => {
43
- const changedFiles = currentChangedFiles ?? new ChangedFiles();
44
- for (const file of changes) {
45
- changedFiles.modified.add(file);
46
- }
47
- for (const file of removals) {
48
- changedFiles.removed.add(file);
49
- }
50
- const next = nextQueue.shift();
51
- if (next) {
52
- currentChangedFiles = undefined;
53
- next(changedFiles);
54
- }
55
- else {
56
- currentChangedFiles = changedFiles;
57
- }
58
- });
59
- return {
60
- [Symbol.asyncIterator]() {
61
- return this;
62
- },
63
- async next() {
64
- if (currentChangedFiles && nextQueue.length === 0) {
65
- const result = { value: currentChangedFiles };
66
- currentChangedFiles = undefined;
67
- return result;
68
- }
69
- return new Promise((resolve) => {
70
- nextQueue.push((value) => resolve(value ? { value } : { done: true, value }));
71
- });
72
- },
73
- add(paths) {
74
- const previousSize = watchedFiles.size;
75
- if (typeof paths === 'string') {
76
- watchedFiles.add(paths);
77
- }
78
- else {
79
- for (const file of paths) {
80
- watchedFiles.add(file);
81
- }
82
- }
83
- if (previousSize !== watchedFiles.size) {
84
- watcher.watch({
85
- files: watchedFiles,
86
- });
87
- }
88
- },
89
- remove(paths) {
90
- const previousSize = watchedFiles.size;
91
- if (typeof paths === 'string') {
92
- watchedFiles.delete(paths);
93
- }
94
- else {
95
- for (const file of paths) {
96
- watchedFiles.delete(file);
97
- }
98
- }
99
- if (previousSize !== watchedFiles.size) {
100
- watcher.watch({
101
- files: watchedFiles,
102
- });
103
- }
104
- },
105
- async close() {
106
- try {
107
- watcher.close();
108
- }
109
- finally {
110
- let next;
111
- while ((next = nextQueue.shift()) !== undefined) {
112
- next();
113
- }
114
- }
115
- },
116
- };
117
- }
118
- exports.createWatcher = createWatcher;
@@ -1,18 +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
- /**
9
- * Scans a CSS or Sass file and locates all valid url function values as defined by the
10
- * syntax specification.
11
- * @param contents A string containing a CSS or Sass file to scan.
12
- * @returns An iterable that yields each CSS url function value found.
13
- */
14
- export declare function findUrls(contents: string): Iterable<{
15
- start: number;
16
- end: number;
17
- value: string;
18
- }>;