@angular-devkit/build-angular 18.0.0-next.2 → 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 (249) hide show
  1. package/builders.json +1 -5
  2. package/package.json +21 -20
  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 +9 -13
  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 +5 -6
  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 +34 -34
  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 +2 -2
  33. package/src/tools/webpack/plugins/any-component-style-budget-checker.js +14 -17
  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 +3 -3
  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 -14
  40. package/src/tools/webpack/utils/stats.js +3 -207
  41. package/src/utils/action-executor.d.ts +1 -1
  42. package/src/utils/i18n-inlining.d.ts +1 -1
  43. package/src/utils/i18n-webpack.d.ts +16 -0
  44. package/src/utils/i18n-webpack.js +107 -0
  45. package/src/utils/index.d.ts +1 -2
  46. package/src/utils/index.js +4 -2
  47. package/src/utils/normalize-builder-schema.js +2 -2
  48. package/src/utils/normalize-cache.js +1 -1
  49. package/src/utils/normalize-optimization.d.ts +1 -1
  50. package/src/utils/normalize-optimization.js +0 -2
  51. package/src/utils/output-paths.d.ts +1 -1
  52. package/src/utils/webpack-browser-config.d.ts +1 -1
  53. package/src/utils/webpack-browser-config.js +2 -2
  54. package/src/builders/application/build-action.d.ts +0 -33
  55. package/src/builders/application/build-action.js +0 -183
  56. package/src/builders/application/execute-build.d.ts +0 -11
  57. package/src/builders/application/execute-build.js +0 -127
  58. package/src/builders/application/execute-post-bundle.d.ts +0 -25
  59. package/src/builders/application/execute-post-bundle.js +0 -96
  60. package/src/builders/application/i18n.d.ts +0 -29
  61. package/src/builders/application/i18n.js +0 -128
  62. package/src/builders/application/index.d.ts +0 -57
  63. package/src/builders/application/index.js +0 -121
  64. package/src/builders/application/options.d.ts +0 -149
  65. package/src/builders/application/options.js +0 -352
  66. package/src/builders/application/schema.d.ts +0 -512
  67. package/src/builders/application/schema.js +0 -58
  68. package/src/builders/application/schema.json +0 -635
  69. package/src/builders/application/setup-bundling.d.ts +0 -19
  70. package/src/builders/application/setup-bundling.js +0 -71
  71. package/src/builders/dev-server/vite-server.d.ts +0 -30
  72. package/src/builders/dev-server/vite-server.js +0 -502
  73. package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -27
  74. package/src/tools/babel/plugins/adjust-static-class-members.js +0 -351
  75. package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -23
  76. package/src/tools/babel/plugins/adjust-typescript-enums.js +0 -113
  77. package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -23
  78. package/src/tools/babel/plugins/elide-angular-metadata.js +0 -110
  79. package/src/tools/babel/plugins/index.d.ts +0 -11
  80. package/src/tools/babel/plugins/index.js +0 -21
  81. package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -16
  82. package/src/tools/babel/plugins/pure-toplevel-functions.js +0 -90
  83. package/src/tools/esbuild/angular/angular-host.d.ts +0 -26
  84. package/src/tools/esbuild/angular/angular-host.js +0 -72
  85. package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +0 -42
  86. package/src/tools/esbuild/angular/compilation/angular-compilation.js +0 -94
  87. package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +0 -21
  88. package/src/tools/esbuild/angular/compilation/aot-compilation.js +0 -228
  89. package/src/tools/esbuild/angular/compilation/factory.d.ts +0 -16
  90. package/src/tools/esbuild/angular/compilation/factory.js +0 -56
  91. package/src/tools/esbuild/angular/compilation/index.d.ts +0 -10
  92. package/src/tools/esbuild/angular/compilation/index.js +0 -17
  93. package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +0 -21
  94. package/src/tools/esbuild/angular/compilation/jit-compilation.js +0 -106
  95. package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +0 -20
  96. package/src/tools/esbuild/angular/compilation/noop-compilation.js +0 -26
  97. package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +0 -42
  98. package/src/tools/esbuild/angular/compilation/parallel-compilation.js +0 -123
  99. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -33
  100. package/src/tools/esbuild/angular/compilation/parallel-worker.js +0 -90
  101. package/src/tools/esbuild/angular/compilation-state.d.ts +0 -15
  102. package/src/tools/esbuild/angular/compilation-state.js +0 -44
  103. package/src/tools/esbuild/angular/compiler-plugin.d.ts +0 -27
  104. package/src/tools/esbuild/angular/compiler-plugin.js +0 -433
  105. package/src/tools/esbuild/angular/component-stylesheets.d.ts +0 -44
  106. package/src/tools/esbuild/angular/component-stylesheets.js +0 -150
  107. package/src/tools/esbuild/angular/diagnostics.d.ts +0 -15
  108. package/src/tools/esbuild/angular/diagnostics.js +0 -69
  109. package/src/tools/esbuild/angular/file-reference-tracker.d.ts +0 -17
  110. package/src/tools/esbuild/angular/file-reference-tracker.js +0 -57
  111. package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +0 -23
  112. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +0 -117
  113. package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +0 -17
  114. package/src/tools/esbuild/angular/jit-resource-transformer.js +0 -186
  115. package/src/tools/esbuild/angular/source-file-cache.d.ts +0 -18
  116. package/src/tools/esbuild/angular/source-file-cache.js +0 -65
  117. package/src/tools/esbuild/angular/uri.d.ts +0 -54
  118. package/src/tools/esbuild/angular/uri.js +0 -74
  119. package/src/tools/esbuild/angular/web-worker-transformer.d.ts +0 -17
  120. package/src/tools/esbuild/angular/web-worker-transformer.js +0 -94
  121. package/src/tools/esbuild/application-code-bundle.d.ts +0 -20
  122. package/src/tools/esbuild/application-code-bundle.js +0 -368
  123. package/src/tools/esbuild/budget-stats.d.ts +0 -19
  124. package/src/tools/esbuild/budget-stats.js +0 -59
  125. package/src/tools/esbuild/bundler-context.d.ts +0 -75
  126. package/src/tools/esbuild/bundler-context.js +0 -366
  127. package/src/tools/esbuild/bundler-execution-result.d.ts +0 -71
  128. package/src/tools/esbuild/bundler-execution-result.js +0 -131
  129. package/src/tools/esbuild/cache.d.ts +0 -88
  130. package/src/tools/esbuild/cache.js +0 -92
  131. package/src/tools/esbuild/commonjs-checker.d.ts +0 -28
  132. package/src/tools/esbuild/commonjs-checker.js +0 -151
  133. package/src/tools/esbuild/compiler-plugin-options.d.ts +0 -16
  134. package/src/tools/esbuild/compiler-plugin-options.js +0 -49
  135. package/src/tools/esbuild/external-packages-plugin.d.ts +0 -18
  136. package/src/tools/esbuild/external-packages-plugin.js +0 -70
  137. package/src/tools/esbuild/global-scripts.d.ts +0 -16
  138. package/src/tools/esbuild/global-scripts.js +0 -142
  139. package/src/tools/esbuild/global-styles.d.ts +0 -10
  140. package/src/tools/esbuild/global-styles.js +0 -74
  141. package/src/tools/esbuild/i18n-inliner-worker.d.ts +0 -42
  142. package/src/tools/esbuild/i18n-inliner-worker.js +0 -136
  143. package/src/tools/esbuild/i18n-inliner.d.ts +0 -44
  144. package/src/tools/esbuild/i18n-inliner.js +0 -150
  145. package/src/tools/esbuild/i18n-locale-plugin.d.ts +0 -22
  146. package/src/tools/esbuild/i18n-locale-plugin.js +0 -120
  147. package/src/tools/esbuild/index-html-generator.d.ts +0 -15
  148. package/src/tools/esbuild/index-html-generator.js +0 -129
  149. package/src/tools/esbuild/javascript-transformer-worker.d.ts +0 -19
  150. package/src/tools/esbuild/javascript-transformer-worker.js +0 -154
  151. package/src/tools/esbuild/javascript-transformer.d.ts +0 -54
  152. package/src/tools/esbuild/javascript-transformer.js +0 -143
  153. package/src/tools/esbuild/license-extractor.d.ts +0 -25
  154. package/src/tools/esbuild/license-extractor.js +0 -158
  155. package/src/tools/esbuild/load-result-cache.d.ts +0 -21
  156. package/src/tools/esbuild/load-result-cache.js +0 -75
  157. package/src/tools/esbuild/profiling.d.ts +0 -11
  158. package/src/tools/esbuild/profiling.js +0 -78
  159. package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +0 -18
  160. package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +0 -44
  161. package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +0 -17
  162. package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +0 -73
  163. package/src/tools/esbuild/stylesheets/bundle-options.d.ts +0 -35
  164. package/src/tools/esbuild/stylesheets/bundle-options.js +0 -64
  165. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +0 -25
  166. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +0 -57
  167. package/src/tools/esbuild/stylesheets/css-language.d.ts +0 -9
  168. package/src/tools/esbuild/stylesheets/css-language.js +0 -15
  169. package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +0 -18
  170. package/src/tools/esbuild/stylesheets/css-resource-plugin.js +0 -107
  171. package/src/tools/esbuild/stylesheets/less-language.d.ts +0 -9
  172. package/src/tools/esbuild/stylesheets/less-language.js +0 -155
  173. package/src/tools/esbuild/stylesheets/sass-language.d.ts +0 -10
  174. package/src/tools/esbuild/stylesheets/sass-language.js +0 -185
  175. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +0 -58
  176. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +0 -282
  177. package/src/tools/esbuild/utils.d.ts +0 -41
  178. package/src/tools/esbuild/utils.js +0 -378
  179. package/src/tools/esbuild/virtual-module-plugin.d.ts +0 -33
  180. package/src/tools/esbuild/virtual-module-plugin.js +0 -43
  181. package/src/tools/esbuild/watcher.d.ts +0 -25
  182. package/src/tools/esbuild/watcher.js +0 -118
  183. package/src/tools/sass/lexer.d.ts +0 -18
  184. package/src/tools/sass/lexer.js +0 -161
  185. package/src/tools/sass/rebasing-importer.d.ts +0 -101
  186. package/src/tools/sass/rebasing-importer.js +0 -337
  187. package/src/tools/sass/sass-service.d.ts +0 -49
  188. package/src/tools/sass/sass-service.js +0 -213
  189. package/src/tools/sass/worker.d.ts +0 -8
  190. package/src/tools/sass/worker.js +0 -164
  191. package/src/tools/vite/angular-memory-plugin.d.ts +0 -24
  192. package/src/tools/vite/angular-memory-plugin.js +0 -268
  193. package/src/tools/vite/i18n-locale-plugin.d.ts +0 -18
  194. package/src/tools/vite/i18n-locale-plugin.js +0 -55
  195. package/src/typings.d.ts +0 -21
  196. package/src/utils/bundle-calculator.d.ts +0 -44
  197. package/src/utils/bundle-calculator.js +0 -302
  198. package/src/utils/check-port.d.ts +0 -8
  199. package/src/utils/check-port.js +0 -58
  200. package/src/utils/delete-output-dir.d.ts +0 -11
  201. package/src/utils/delete-output-dir.js +0 -46
  202. package/src/utils/i18n-options.d.ts +0 -40
  203. package/src/utils/i18n-options.js +0 -254
  204. package/src/utils/index-file/augment-index-html.d.ts +0 -40
  205. package/src/utils/index-file/augment-index-html.js +0 -238
  206. package/src/utils/index-file/html-rewriting-stream.d.ts +0 -11
  207. package/src/utils/index-file/html-rewriting-stream.js +0 -28
  208. package/src/utils/index-file/index-html-generator.d.ts +0 -47
  209. package/src/utils/index-file/index-html-generator.js +0 -119
  210. package/src/utils/index-file/inline-critical-css.d.ts +0 -24
  211. package/src/utils/index-file/inline-critical-css.js +0 -179
  212. package/src/utils/index-file/inline-fonts.d.ts +0 -23
  213. package/src/utils/index-file/inline-fonts.js +0 -267
  214. package/src/utils/index-file/style-nonce.d.ts +0 -12
  215. package/src/utils/index-file/style-nonce.js +0 -53
  216. package/src/utils/load-proxy-config.d.ts +0 -8
  217. package/src/utils/load-proxy-config.js +0 -192
  218. package/src/utils/load-translations.d.ts +0 -16
  219. package/src/utils/load-translations.js +0 -84
  220. package/src/utils/postcss-configuration.d.ts +0 -17
  221. package/src/utils/postcss-configuration.js +0 -86
  222. package/src/utils/purge-cache.d.ts +0 -10
  223. package/src/utils/purge-cache.js +0 -40
  224. package/src/utils/routes-extractor/extractor.d.ts +0 -15
  225. package/src/utils/routes-extractor/extractor.js +0 -97
  226. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +0 -18
  227. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -129
  228. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +0 -8
  229. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +0 -13
  230. package/src/utils/server-rendering/fetch-patch.d.ts +0 -8
  231. package/src/utils/server-rendering/fetch-patch.js +0 -66
  232. package/src/utils/server-rendering/load-esm-from-memory.d.ts +0 -10
  233. package/src/utils/server-rendering/load-esm-from-memory.js +0 -26
  234. package/src/utils/server-rendering/main-bundle-exports.d.ts +0 -27
  235. package/src/utils/server-rendering/main-bundle-exports.js +0 -9
  236. package/src/utils/server-rendering/prerender.d.ts +0 -23
  237. package/src/utils/server-rendering/prerender.js +0 -192
  238. package/src/utils/server-rendering/render-page.d.ts +0 -26
  239. package/src/utils/server-rendering/render-page.js +0 -110
  240. package/src/utils/server-rendering/render-worker.d.ts +0 -22
  241. package/src/utils/server-rendering/render-worker.js +0 -30
  242. package/src/utils/server-rendering/routes-extractor-worker.d.ts +0 -21
  243. package/src/utils/server-rendering/routes-extractor-worker.js +0 -53
  244. package/src/utils/service-worker.d.ts +0 -25
  245. package/src/utils/service-worker.js +0 -211
  246. package/src/utils/supported-browsers.d.ts +0 -10
  247. package/src/utils/supported-browsers.js +0 -42
  248. package/src/utils/version.d.ts +0 -8
  249. package/src/utils/version.js +0 -59
@@ -33,26 +33,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.webpackStatsLogger = exports.generateBuildEventStats = exports.createWebpackLoggingCallback = exports.statsHasWarnings = exports.statsHasErrors = exports.statsErrorsToString = exports.statsWarningsToString = exports.generateBuildStatsTable = exports.generateEsbuildBuildStatsTable = exports.formatSize = void 0;
36
+ exports.webpackStatsLogger = exports.generateBuildEventStats = exports.createWebpackLoggingCallback = exports.statsHasWarnings = exports.statsHasErrors = exports.statsErrorsToString = exports.statsWarningsToString = void 0;
37
+ const private_1 = require("@angular/build/private");
37
38
  const node_assert_1 = __importDefault(require("node:assert"));
38
39
  const path = __importStar(require("node:path"));
39
- const node_util_1 = require("node:util");
40
40
  const utils_1 = require("../../../utils");
41
41
  const color_1 = require("../../../utils/color");
42
42
  const async_chunks_1 = require("./async-chunks");
43
43
  const helpers_1 = require("./helpers");
44
- function formatSize(size) {
45
- if (size <= 0) {
46
- return '0 bytes';
47
- }
48
- const abbreviations = ['bytes', 'kB', 'MB', 'GB'];
49
- const index = Math.floor(Math.log(size) / Math.log(1024));
50
- const roundedSize = size / Math.pow(1024, index);
51
- // bytes don't have a fraction
52
- const fractionDigits = index === 0 ? 0 : 2;
53
- return `${roundedSize.toFixed(fractionDigits)} ${abbreviations[index]}`;
54
- }
55
- exports.formatSize = formatSize;
56
44
  function getBuildDuration(webpackStats) {
57
45
  (0, node_assert_1.default)(webpackStats.builtAt, 'buildAt cannot be undefined');
58
46
  (0, node_assert_1.default)(webpackStats.time, 'time cannot be undefined');
@@ -72,198 +60,6 @@ function generateBundleStats(info) {
72
60
  stats: [files, names, rawSize, estimatedTransferSize],
73
61
  };
74
62
  }
75
- function generateEsbuildBuildStatsTable([browserStats, serverStats], colors, showTotalSize, showEstimatedTransferSize, budgetFailures, verbose) {
76
- const bundleInfo = generateBuildStatsData(browserStats, colors, showTotalSize, showEstimatedTransferSize, budgetFailures, verbose);
77
- if (serverStats.length) {
78
- const m = (x) => (colors ? color_1.colors.magenta(x) : x);
79
- if (browserStats.length) {
80
- bundleInfo.unshift([m('Browser bundles')]);
81
- // Add seperators between browser and server logs
82
- bundleInfo.push([], []);
83
- }
84
- bundleInfo.push([m('Server bundles')], ...generateBuildStatsData(serverStats, colors, false, false, undefined, verbose));
85
- }
86
- return generateTableText(bundleInfo, colors);
87
- }
88
- exports.generateEsbuildBuildStatsTable = generateEsbuildBuildStatsTable;
89
- function generateBuildStatsTable(data, colors, showTotalSize, showEstimatedTransferSize, budgetFailures) {
90
- const bundleInfo = generateBuildStatsData(data, colors, showTotalSize, showEstimatedTransferSize, budgetFailures, true);
91
- return generateTableText(bundleInfo, colors);
92
- }
93
- exports.generateBuildStatsTable = generateBuildStatsTable;
94
- function generateBuildStatsData(data, colors, showTotalSize, showEstimatedTransferSize, budgetFailures, verbose) {
95
- if (data.length === 0) {
96
- return [];
97
- }
98
- const g = (x) => (colors ? color_1.colors.green(x) : x);
99
- const c = (x) => (colors ? color_1.colors.cyan(x) : x);
100
- const r = (x) => (colors ? color_1.colors.redBright(x) : x);
101
- const y = (x) => (colors ? color_1.colors.yellowBright(x) : x);
102
- const bold = (x) => (colors ? color_1.colors.bold(x) : x);
103
- const dim = (x) => (colors ? color_1.colors.dim(x) : x);
104
- const getSizeColor = (name, file, defaultColor = c) => {
105
- const severity = budgets.get(name) || (file && budgets.get(file));
106
- switch (severity) {
107
- case 'warning':
108
- return y;
109
- case 'error':
110
- return r;
111
- default:
112
- return defaultColor;
113
- }
114
- };
115
- const changedEntryChunksStats = [];
116
- const changedLazyChunksStats = [];
117
- let initialTotalRawSize = 0;
118
- let changedLazyChunksCount = 0;
119
- let initialTotalEstimatedTransferSize;
120
- const maxLazyChunksWithoutBudgetFailures = 15;
121
- const budgets = new Map();
122
- if (budgetFailures) {
123
- for (const { label, severity } of budgetFailures) {
124
- // In some cases a file can have multiple budget failures.
125
- // Favor error.
126
- if (label && (!budgets.has(label) || budgets.get(label) === 'warning')) {
127
- budgets.set(label, severity);
128
- }
129
- }
130
- }
131
- // Sort descending by raw size
132
- data.sort((a, b) => {
133
- if (a.stats[2] > b.stats[2]) {
134
- return -1;
135
- }
136
- if (a.stats[2] < b.stats[2]) {
137
- return 1;
138
- }
139
- return 0;
140
- });
141
- for (const { initial, stats } of data) {
142
- const [files, names, rawSize, estimatedTransferSize] = stats;
143
- if (!initial &&
144
- !verbose &&
145
- changedLazyChunksStats.length >= maxLazyChunksWithoutBudgetFailures &&
146
- !budgets.has(names) &&
147
- !budgets.has(files)) {
148
- // Limit the number of lazy chunks displayed in the stats table when there is no budget failure and not in verbose mode.
149
- changedLazyChunksCount++;
150
- continue;
151
- }
152
- const getRawSizeColor = getSizeColor(names, files);
153
- let data;
154
- if (showEstimatedTransferSize) {
155
- data = [
156
- g(files),
157
- dim(names),
158
- getRawSizeColor(typeof rawSize === 'number' ? formatSize(rawSize) : rawSize),
159
- c(typeof estimatedTransferSize === 'number'
160
- ? formatSize(estimatedTransferSize)
161
- : estimatedTransferSize),
162
- ];
163
- }
164
- else {
165
- data = [
166
- g(files),
167
- dim(names),
168
- getRawSizeColor(typeof rawSize === 'number' ? formatSize(rawSize) : rawSize),
169
- '',
170
- ];
171
- }
172
- if (initial) {
173
- changedEntryChunksStats.push(data);
174
- if (typeof rawSize === 'number') {
175
- initialTotalRawSize += rawSize;
176
- }
177
- if (showEstimatedTransferSize && typeof estimatedTransferSize === 'number') {
178
- if (initialTotalEstimatedTransferSize === undefined) {
179
- initialTotalEstimatedTransferSize = 0;
180
- }
181
- initialTotalEstimatedTransferSize += estimatedTransferSize;
182
- }
183
- }
184
- else {
185
- changedLazyChunksStats.push(data);
186
- changedLazyChunksCount++;
187
- }
188
- }
189
- const bundleInfo = [];
190
- const baseTitles = ['Names', 'Raw size'];
191
- if (showEstimatedTransferSize) {
192
- baseTitles.push('Estimated transfer size');
193
- }
194
- // Entry chunks
195
- if (changedEntryChunksStats.length) {
196
- bundleInfo.push(['Initial chunk files', ...baseTitles].map(bold), ...changedEntryChunksStats);
197
- if (showTotalSize) {
198
- const initialSizeTotalColor = getSizeColor('bundle initial', undefined, (x) => x);
199
- const totalSizeElements = [
200
- ' ',
201
- 'Initial total',
202
- initialSizeTotalColor(formatSize(initialTotalRawSize)),
203
- ];
204
- if (showEstimatedTransferSize) {
205
- totalSizeElements.push(typeof initialTotalEstimatedTransferSize === 'number'
206
- ? formatSize(initialTotalEstimatedTransferSize)
207
- : '-');
208
- }
209
- bundleInfo.push([], totalSizeElements.map(bold));
210
- }
211
- }
212
- // Seperator
213
- if (changedEntryChunksStats.length && changedLazyChunksStats.length) {
214
- bundleInfo.push([]);
215
- }
216
- // Lazy chunks
217
- if (changedLazyChunksStats.length) {
218
- bundleInfo.push(['Lazy chunk files', ...baseTitles].map(bold), ...changedLazyChunksStats);
219
- if (changedLazyChunksCount > changedLazyChunksStats.length) {
220
- bundleInfo.push([
221
- dim(`...and ${changedLazyChunksCount - changedLazyChunksStats.length} more lazy chunks files. ` +
222
- 'Use "--verbose" to show all the files.'),
223
- ]);
224
- }
225
- }
226
- return bundleInfo;
227
- }
228
- function generateTableText(bundleInfo, colors) {
229
- const skipText = (value) => value.includes('...and ');
230
- const longest = [];
231
- for (const item of bundleInfo) {
232
- for (let i = 0; i < item.length; i++) {
233
- if (item[i] === undefined) {
234
- continue;
235
- }
236
- const currentItem = item[i].toString();
237
- if (skipText(currentItem)) {
238
- continue;
239
- }
240
- const currentLongest = (longest[i] ??= 0);
241
- const currentItemLength = (0, node_util_1.stripVTControlCharacters)(currentItem).length;
242
- if (currentLongest < currentItemLength) {
243
- longest[i] = currentItemLength;
244
- }
245
- }
246
- }
247
- const seperator = colors ? color_1.colors.dim(' | ') : ' | ';
248
- const outputTable = [];
249
- for (const item of bundleInfo) {
250
- for (let i = 0; i < longest.length; i++) {
251
- if (item[i] === undefined) {
252
- continue;
253
- }
254
- const currentItem = item[i].toString();
255
- if (skipText(currentItem)) {
256
- continue;
257
- }
258
- const currentItemLength = (0, node_util_1.stripVTControlCharacters)(currentItem).length;
259
- const stringPad = ' '.repeat(longest[i] - currentItemLength);
260
- // Values in columns at index 2 and 3 (Raw and Estimated sizes) are always right aligned.
261
- item[i] = i >= 2 ? stringPad + currentItem : currentItem + stringPad;
262
- }
263
- outputTable.push(item.join(seperator));
264
- }
265
- return outputTable.join('\n');
266
- }
267
63
  // We use this cache because we can have multiple builders running in the same process,
268
64
  // where each builder has different output path.
269
65
  // Ideally, we should create the logging callback as a factory, but that would need a refactoring.
@@ -309,7 +105,7 @@ statsConfig, budgetFailures) {
309
105
  }
310
106
  unchangedChunkNumber = json.chunks.length - changedChunksStats.length;
311
107
  runsCache.add(json.outputPath || '');
312
- const statsTable = generateBuildStatsTable(changedChunksStats, colors, unchangedChunkNumber === 0, hasEstimatedTransferSizes, budgetFailures);
108
+ const statsTable = (0, private_1.generateBuildStatsTable)(changedChunksStats, colors, unchangedChunkNumber === 0, hasEstimatedTransferSizes, budgetFailures);
313
109
  // In some cases we do things outside of webpack context
314
110
  // Such us index generation, service worker augmentation etc...
315
111
  // This will correct the time and include these.
@@ -6,7 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { InlineOptions } from './bundle-inline-options';
9
- import { I18nOptions } from './i18n-options';
9
+ import { I18nOptions } from './i18n-webpack';
10
10
  export declare class BundleActionExecutor {
11
11
  private workerOptions;
12
12
  private workerPool?;
@@ -7,5 +7,5 @@
7
7
  */
8
8
  import { BuilderContext } from '@angular-devkit/architect';
9
9
  import { EmittedFiles } from '@angular-devkit/build-webpack';
10
- import { I18nOptions } from './i18n-options';
10
+ import { I18nOptions } from './i18n-webpack';
11
11
  export declare function i18nInlineEmittedFiles(context: BuilderContext, emittedFiles: EmittedFiles[], i18n: I18nOptions, baseOutputPath: string, outputPaths: string[], scriptsEntryPointName: string[], emittedPath: string, missingTranslation: 'error' | 'warning' | 'ignore' | undefined): Promise<boolean>;
@@ -0,0 +1,16 @@
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 I18nOptions, loadTranslations } from '@angular/build/private';
9
+ import { BuilderContext } from '@angular-devkit/architect';
10
+ import { Schema as BrowserBuilderSchema } from '../builders/browser/schema';
11
+ import { Schema as ServerBuilderSchema } from '../builders/server/schema';
12
+ export { I18nOptions, loadTranslations };
13
+ export declare function configureI18nBuild<T extends BrowserBuilderSchema | ServerBuilderSchema>(context: BuilderContext, options: T): Promise<{
14
+ buildOptions: T;
15
+ i18n: I18nOptions;
16
+ }>;
@@ -0,0 +1,107 @@
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.configureI18nBuild = exports.loadTranslations = void 0;
14
+ const private_1 = require("@angular/build/private");
15
+ Object.defineProperty(exports, "loadTranslations", { enumerable: true, get: function () { return private_1.loadTranslations; } });
16
+ const node_fs_1 = __importDefault(require("node:fs"));
17
+ const node_module_1 = require("node:module");
18
+ const node_os_1 = __importDefault(require("node:os"));
19
+ const node_path_1 = __importDefault(require("node:path"));
20
+ const read_tsconfig_1 = require("../utils/read-tsconfig");
21
+ /**
22
+ * The base module location used to search for locale specific data.
23
+ */
24
+ const LOCALE_DATA_BASE_MODULE = '@angular/common/locales/global';
25
+ async function configureI18nBuild(context, options) {
26
+ if (!context.target) {
27
+ throw new Error('The builder requires a target.');
28
+ }
29
+ const buildOptions = { ...options };
30
+ const tsConfig = await (0, read_tsconfig_1.readTsconfig)(buildOptions.tsConfig, context.workspaceRoot);
31
+ const metadata = await context.getProjectMetadata(context.target);
32
+ const i18n = (0, private_1.createI18nOptions)(metadata, buildOptions.localize);
33
+ // No additional processing needed if no inlining requested and no source locale defined.
34
+ if (!i18n.shouldInline && !i18n.hasDefinedSourceLocale) {
35
+ return { buildOptions, i18n };
36
+ }
37
+ const projectRoot = node_path_1.default.join(context.workspaceRoot, metadata.root || '');
38
+ // The trailing slash is required to signal that the path is a directory and not a file.
39
+ const projectRequire = (0, node_module_1.createRequire)(projectRoot + '/');
40
+ const localeResolver = (locale) => projectRequire.resolve(node_path_1.default.join(LOCALE_DATA_BASE_MODULE, locale));
41
+ // Load locale data and translations (if present)
42
+ let loader;
43
+ const usedFormats = new Set();
44
+ for (const [locale, desc] of Object.entries(i18n.locales)) {
45
+ if (!i18n.inlineLocales.has(locale) && locale !== i18n.sourceLocale) {
46
+ continue;
47
+ }
48
+ let localeDataPath = findLocaleDataPath(locale, localeResolver);
49
+ if (!localeDataPath) {
50
+ const [first] = locale.split('-');
51
+ if (first) {
52
+ localeDataPath = findLocaleDataPath(first.toLowerCase(), localeResolver);
53
+ if (localeDataPath) {
54
+ context.logger.warn(`Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`);
55
+ }
56
+ }
57
+ }
58
+ if (!localeDataPath) {
59
+ context.logger.warn(`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`);
60
+ }
61
+ else {
62
+ desc.dataPath = localeDataPath;
63
+ }
64
+ if (!desc.files.length) {
65
+ continue;
66
+ }
67
+ loader ??= await (0, private_1.createTranslationLoader)();
68
+ (0, private_1.loadTranslations)(locale, desc, context.workspaceRoot, loader, {
69
+ warn(message) {
70
+ context.logger.warn(message);
71
+ },
72
+ error(message) {
73
+ throw new Error(message);
74
+ },
75
+ }, usedFormats, buildOptions.i18nDuplicateTranslation);
76
+ if (usedFormats.size > 1 && tsConfig.options.enableI18nLegacyMessageIdFormat !== false) {
77
+ // This limitation is only for legacy message id support (defaults to true as of 9.0)
78
+ throw new Error('Localization currently only supports using one type of translation file format for the entire application.');
79
+ }
80
+ }
81
+ // If inlining store the output in a temporary location to facilitate post-processing
82
+ if (i18n.shouldInline) {
83
+ // TODO: we should likely save these in the .angular directory in the next major version.
84
+ // We'd need to do a migration to add the temp directory to gitignore.
85
+ const tempPath = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_fs_1.default.realpathSync(node_os_1.default.tmpdir()), 'angular-cli-i18n-'));
86
+ buildOptions.outputPath = tempPath;
87
+ process.on('exit', () => {
88
+ try {
89
+ node_fs_1.default.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
90
+ }
91
+ catch { }
92
+ });
93
+ }
94
+ return { buildOptions, i18n };
95
+ }
96
+ exports.configureI18nBuild = configureI18nBuild;
97
+ function findLocaleDataPath(locale, resolver) {
98
+ // Remove private use subtags
99
+ const scrubbedLocale = locale.replace(/-x(-[a-zA-Z0-9]{1,8})+$/, '');
100
+ try {
101
+ return resolver(scrubbedLocale);
102
+ }
103
+ catch {
104
+ // fallback to known existing en-US locale data as of 14.0
105
+ return scrubbedLocale === 'en-US' ? findLocaleDataPath('en', resolver) : null;
106
+ }
107
+ }
@@ -6,9 +6,8 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  export * from './default-progress';
9
- export * from './delete-output-dir';
9
+ export { deleteOutputDir, loadProxyConfiguration } from '@angular/build/private';
10
10
  export * from './run-module-as-observable-fork';
11
- export * from './load-proxy-config';
12
11
  export * from './normalize-file-replacements';
13
12
  export * from './normalize-asset-patterns';
14
13
  export * from './normalize-source-maps';
@@ -21,10 +21,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
21
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.loadProxyConfiguration = exports.deleteOutputDir = void 0;
24
25
  __exportStar(require("./default-progress"), exports);
25
- __exportStar(require("./delete-output-dir"), exports);
26
+ var private_1 = require("@angular/build/private");
27
+ Object.defineProperty(exports, "deleteOutputDir", { enumerable: true, get: function () { return private_1.deleteOutputDir; } });
28
+ Object.defineProperty(exports, "loadProxyConfiguration", { enumerable: true, get: function () { return private_1.loadProxyConfiguration; } });
26
29
  __exportStar(require("./run-module-as-observable-fork"), exports);
27
- __exportStar(require("./load-proxy-config"), exports);
28
30
  __exportStar(require("./normalize-file-replacements"), exports);
29
31
  __exportStar(require("./normalize-asset-patterns"), exports);
30
32
  __exportStar(require("./normalize-source-maps"), exports);
@@ -8,13 +8,13 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeBrowserSchema = void 0;
11
+ const private_1 = require("@angular/build/private");
11
12
  const normalize_asset_patterns_1 = require("./normalize-asset-patterns");
12
13
  const normalize_cache_1 = require("./normalize-cache");
13
14
  const normalize_file_replacements_1 = require("./normalize-file-replacements");
14
15
  const normalize_optimization_1 = require("./normalize-optimization");
15
16
  const normalize_polyfills_1 = require("./normalize-polyfills");
16
17
  const normalize_source_maps_1 = require("./normalize-source-maps");
17
- const supported_browsers_1 = require("./supported-browsers");
18
18
  function normalizeBrowserSchema(workspaceRoot, projectRoot, projectSourceRoot, options, metadata, logger) {
19
19
  return {
20
20
  ...options,
@@ -38,7 +38,7 @@ function normalizeBrowserSchema(workspaceRoot, projectRoot, projectSourceRoot, o
38
38
  // A value of 0 is falsy and will disable polling rather then enable
39
39
  // 500 ms is a sensible default in this case
40
40
  poll: options.poll === 0 ? 500 : options.poll,
41
- supportedBrowsers: (0, supported_browsers_1.getSupportedBrowsers)(projectRoot, logger),
41
+ supportedBrowsers: (0, private_1.getSupportedBrowsers)(projectRoot, logger),
42
42
  };
43
43
  }
44
44
  exports.normalizeBrowserSchema = normalizeBrowserSchema;
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeCacheOptions = void 0;
11
11
  const node_path_1 = require("node:path");
12
12
  /** Version placeholder is replaced during the build process with actual package version */
13
- const VERSION = '18.0.0-next.2';
13
+ const VERSION = '18.0.0-next.4';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&
@@ -5,7 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { FontsClass, OptimizationClass, OptimizationUnion, StylesClass } from '../builders/application/schema';
8
+ import { FontsClass, OptimizationClass, OptimizationUnion, StylesClass } from '../builders/browser/schema';
9
9
  export type NormalizedOptimizationOptions = Required<Omit<OptimizationClass, 'fonts' | 'styles'>> & {
10
10
  fonts: FontsClass;
11
11
  styles: StylesClass;
@@ -17,7 +17,6 @@ function normalizeOptimization(optimization = true) {
17
17
  ? optimization.styles
18
18
  : {
19
19
  minify: styleOptimization,
20
- removeSpecialComments: styleOptimization,
21
20
  inlineCritical: styleOptimization,
22
21
  },
23
22
  fonts: typeof optimization.fonts === 'object'
@@ -32,7 +31,6 @@ function normalizeOptimization(optimization = true) {
32
31
  styles: {
33
32
  minify: optimization,
34
33
  inlineCritical: optimization,
35
- removeSpecialComments: optimization,
36
34
  },
37
35
  fonts: {
38
36
  inline: optimization,
@@ -5,5 +5,5 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { I18nOptions } from './i18n-options';
8
+ import { I18nOptions } from './i18n-webpack';
9
9
  export declare function ensureOutputPaths(baseOutputPath: string, i18n: I18nOptions): Map<string, string>;
@@ -10,7 +10,7 @@ import { Configuration } from 'webpack';
10
10
  import { Schema as BrowserBuilderSchema } from '../builders/browser/schema';
11
11
  import { NormalizedBrowserBuilderSchema } from '../utils';
12
12
  import { WebpackConfigOptions } from '../utils/build-options';
13
- import { I18nOptions } from './i18n-options';
13
+ import { I18nOptions } from './i18n-webpack';
14
14
  export type BrowserWebpackConfigOptions = WebpackConfigOptions<NormalizedBrowserBuilderSchema>;
15
15
  export type WebpackPartialGenerator = (configurationOptions: BrowserWebpackConfigOptions) => (Promise<Configuration> | Configuration)[];
16
16
  export declare function generateWebpackConfig(workspaceRoot: string, projectRoot: string, sourceRoot: string | undefined, projectName: string, options: NormalizedBrowserBuilderSchema, webpackPartialGenerator: WebpackPartialGenerator, logger: BuilderContext['logger'], extraBuildOptions: Partial<NormalizedBrowserBuilderSchema>): Promise<Configuration>;
@@ -37,7 +37,7 @@ const webpack_merge_1 = require("webpack-merge");
37
37
  const builder_watch_plugin_1 = require("../tools/webpack/plugins/builder-watch-plugin");
38
38
  const utils_1 = require("../utils");
39
39
  const read_tsconfig_1 = require("../utils/read-tsconfig");
40
- const i18n_options_1 = require("./i18n-options");
40
+ const i18n_webpack_1 = require("./i18n-webpack");
41
41
  async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, projectName, options, webpackPartialGenerator, logger, extraBuildOptions) {
42
42
  // Ensure Build Optimizer is only used with AOT.
43
43
  if (options.buildOptimizer && !options.aot) {
@@ -63,7 +63,7 @@ async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, pro
63
63
  }
64
64
  exports.generateWebpackConfig = generateWebpackConfig;
65
65
  async function generateI18nBrowserWebpackConfigFromContext(options, context, webpackPartialGenerator, extraBuildOptions = {}) {
66
- const { buildOptions, i18n } = await (0, i18n_options_1.configureI18nBuild)(context, options);
66
+ const { buildOptions, i18n } = await (0, i18n_webpack_1.configureI18nBuild)(context, options);
67
67
  const result = await generateBrowserWebpackConfigFromContext(buildOptions, context, (wco) => {
68
68
  return webpackPartialGenerator(wco);
69
69
  }, extraBuildOptions);
@@ -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 { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
9
- import { BuildOutputFile } from '../../tools/esbuild/bundler-context';
10
- import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
11
- import { NormalizedCachedOptions } from '../../utils/normalize-cache';
12
- import { NormalizedOutputOptions } from './options';
13
- type BuildActionOutput = (ExecutionResult['outputWithFiles'] | ExecutionResult['output']) & BuilderOutput;
14
- export declare function runEsBuildBuildAction(action: (rebuildState?: RebuildState) => Promise<ExecutionResult>, options: {
15
- workspaceRoot: string;
16
- projectRoot: string;
17
- outputOptions: NormalizedOutputOptions;
18
- logger: BuilderContext['logger'];
19
- cacheOptions: NormalizedCachedOptions;
20
- writeToFileSystem: boolean;
21
- writeToFileSystemFilter: ((file: BuildOutputFile) => boolean) | undefined;
22
- watch?: boolean;
23
- verbose?: boolean;
24
- progress?: boolean;
25
- deleteOutputPath?: boolean;
26
- poll?: number;
27
- signal?: AbortSignal;
28
- preserveSymlinks?: boolean;
29
- clearScreen?: boolean;
30
- colors?: boolean;
31
- jsonLogs?: boolean;
32
- }): AsyncIterable<BuildActionOutput>;
33
- export {};