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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/builders.json +1 -5
  2. package/package.json +14 -13
  3. package/src/builders/app-shell/index.js +3 -5
  4. package/src/builders/browser/index.d.ts +1 -1
  5. package/src/builders/browser/index.js +8 -12
  6. package/src/builders/browser-esbuild/index.d.ts +2 -2
  7. package/src/builders/browser-esbuild/index.js +6 -9
  8. package/src/builders/dev-server/builder.d.ts +2 -2
  9. package/src/builders/dev-server/builder.js +11 -6
  10. package/src/builders/dev-server/index.d.ts +1 -1
  11. package/src/builders/dev-server/webpack-server.d.ts +1 -1
  12. package/src/builders/dev-server/webpack-server.js +3 -4
  13. package/src/builders/extract-i18n/application-extraction.js +2 -2
  14. package/src/builders/extract-i18n/builder.js +3 -4
  15. package/src/builders/extract-i18n/options.d.ts +1 -1
  16. package/src/builders/extract-i18n/options.js +2 -2
  17. package/src/builders/jest/index.js +2 -2
  18. package/src/builders/karma/index.js +3 -4
  19. package/src/builders/ng-packagr/index.js +8 -7
  20. package/src/builders/ng-packagr/schema.d.ts +4 -0
  21. package/src/builders/ng-packagr/schema.json +4 -0
  22. package/src/builders/prerender/index.js +2 -2
  23. package/src/builders/prerender/render-worker.js +1 -1
  24. package/src/builders/server/index.js +3 -4
  25. package/src/builders/server/platform-server-exports-loader.js +2 -1
  26. package/src/builders/ssr-dev-server/index.js +7 -7
  27. package/src/builders/web-test-runner/index.js +2 -2
  28. package/src/index.d.ts +1 -1
  29. package/src/index.js +2 -2
  30. package/src/tools/babel/presets/application.js +1 -1
  31. package/src/tools/webpack/configs/styles.js +2 -2
  32. package/src/tools/webpack/plugins/any-component-style-budget-checker.d.ts +1 -1
  33. package/src/tools/webpack/plugins/any-component-style-budget-checker.js +5 -5
  34. package/src/tools/webpack/plugins/css-optimizer-plugin.js +2 -2
  35. package/src/tools/webpack/plugins/index-html-webpack-plugin.d.ts +1 -1
  36. package/src/tools/webpack/plugins/index-html-webpack-plugin.js +2 -2
  37. package/src/tools/webpack/plugins/javascript-optimizer-plugin.js +2 -2
  38. package/src/tools/webpack/plugins/service-worker-plugin.js +2 -2
  39. package/src/tools/webpack/utils/stats.d.ts +1 -1
  40. package/src/tools/webpack/utils/stats.js +2 -2
  41. package/src/utils/i18n-webpack.d.ts +1 -1
  42. package/src/utils/i18n-webpack.js +5 -6
  43. package/src/utils/index.d.ts +1 -2
  44. package/src/utils/index.js +4 -2
  45. package/src/utils/normalize-builder-schema.js +2 -2
  46. package/src/utils/normalize-cache.js +1 -1
  47. package/src/utils/normalize-optimization.d.ts +1 -1
  48. package/src/utils/normalize-optimization.js +0 -2
  49. package/src/builders/application/build-action.d.ts +0 -33
  50. package/src/builders/application/build-action.js +0 -183
  51. package/src/builders/application/execute-build.d.ts +0 -11
  52. package/src/builders/application/execute-build.js +0 -125
  53. package/src/builders/application/execute-post-bundle.d.ts +0 -25
  54. package/src/builders/application/execute-post-bundle.js +0 -93
  55. package/src/builders/application/i18n.d.ts +0 -29
  56. package/src/builders/application/i18n.js +0 -128
  57. package/src/builders/application/index.d.ts +0 -57
  58. package/src/builders/application/index.js +0 -121
  59. package/src/builders/application/options.d.ts +0 -149
  60. package/src/builders/application/options.js +0 -369
  61. package/src/builders/application/schema.d.ts +0 -512
  62. package/src/builders/application/schema.js +0 -58
  63. package/src/builders/application/schema.json +0 -635
  64. package/src/builders/application/setup-bundling.d.ts +0 -19
  65. package/src/builders/application/setup-bundling.js +0 -71
  66. package/src/builders/dev-server/vite-server.d.ts +0 -30
  67. package/src/builders/dev-server/vite-server.js +0 -502
  68. package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -27
  69. package/src/tools/babel/plugins/adjust-static-class-members.js +0 -351
  70. package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -23
  71. package/src/tools/babel/plugins/adjust-typescript-enums.js +0 -113
  72. package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -23
  73. package/src/tools/babel/plugins/elide-angular-metadata.js +0 -110
  74. package/src/tools/babel/plugins/index.d.ts +0 -11
  75. package/src/tools/babel/plugins/index.js +0 -21
  76. package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -16
  77. package/src/tools/babel/plugins/pure-toplevel-functions.js +0 -90
  78. package/src/tools/esbuild/angular/angular-host.d.ts +0 -26
  79. package/src/tools/esbuild/angular/angular-host.js +0 -72
  80. package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +0 -42
  81. package/src/tools/esbuild/angular/compilation/angular-compilation.js +0 -94
  82. package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +0 -21
  83. package/src/tools/esbuild/angular/compilation/aot-compilation.js +0 -228
  84. package/src/tools/esbuild/angular/compilation/factory.d.ts +0 -16
  85. package/src/tools/esbuild/angular/compilation/factory.js +0 -56
  86. package/src/tools/esbuild/angular/compilation/index.d.ts +0 -10
  87. package/src/tools/esbuild/angular/compilation/index.js +0 -17
  88. package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +0 -21
  89. package/src/tools/esbuild/angular/compilation/jit-compilation.js +0 -106
  90. package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +0 -20
  91. package/src/tools/esbuild/angular/compilation/noop-compilation.js +0 -26
  92. package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +0 -42
  93. package/src/tools/esbuild/angular/compilation/parallel-compilation.js +0 -123
  94. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -33
  95. package/src/tools/esbuild/angular/compilation/parallel-worker.js +0 -90
  96. package/src/tools/esbuild/angular/compilation-state.d.ts +0 -15
  97. package/src/tools/esbuild/angular/compilation-state.js +0 -44
  98. package/src/tools/esbuild/angular/compiler-plugin.d.ts +0 -27
  99. package/src/tools/esbuild/angular/compiler-plugin.js +0 -441
  100. package/src/tools/esbuild/angular/component-stylesheets.d.ts +0 -44
  101. package/src/tools/esbuild/angular/component-stylesheets.js +0 -150
  102. package/src/tools/esbuild/angular/diagnostics.d.ts +0 -15
  103. package/src/tools/esbuild/angular/diagnostics.js +0 -69
  104. package/src/tools/esbuild/angular/file-reference-tracker.d.ts +0 -17
  105. package/src/tools/esbuild/angular/file-reference-tracker.js +0 -57
  106. package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +0 -23
  107. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +0 -117
  108. package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +0 -17
  109. package/src/tools/esbuild/angular/jit-resource-transformer.js +0 -186
  110. package/src/tools/esbuild/angular/source-file-cache.d.ts +0 -18
  111. package/src/tools/esbuild/angular/source-file-cache.js +0 -65
  112. package/src/tools/esbuild/angular/uri.d.ts +0 -54
  113. package/src/tools/esbuild/angular/uri.js +0 -74
  114. package/src/tools/esbuild/angular/web-worker-transformer.d.ts +0 -17
  115. package/src/tools/esbuild/angular/web-worker-transformer.js +0 -94
  116. package/src/tools/esbuild/application-code-bundle.d.ts +0 -20
  117. package/src/tools/esbuild/application-code-bundle.js +0 -368
  118. package/src/tools/esbuild/budget-stats.d.ts +0 -19
  119. package/src/tools/esbuild/budget-stats.js +0 -59
  120. package/src/tools/esbuild/bundler-context.d.ts +0 -75
  121. package/src/tools/esbuild/bundler-context.js +0 -366
  122. package/src/tools/esbuild/bundler-execution-result.d.ts +0 -71
  123. package/src/tools/esbuild/bundler-execution-result.js +0 -131
  124. package/src/tools/esbuild/cache.d.ts +0 -88
  125. package/src/tools/esbuild/cache.js +0 -92
  126. package/src/tools/esbuild/commonjs-checker.d.ts +0 -28
  127. package/src/tools/esbuild/commonjs-checker.js +0 -151
  128. package/src/tools/esbuild/compiler-plugin-options.d.ts +0 -16
  129. package/src/tools/esbuild/compiler-plugin-options.js +0 -49
  130. package/src/tools/esbuild/external-packages-plugin.d.ts +0 -18
  131. package/src/tools/esbuild/external-packages-plugin.js +0 -70
  132. package/src/tools/esbuild/global-scripts.d.ts +0 -16
  133. package/src/tools/esbuild/global-scripts.js +0 -142
  134. package/src/tools/esbuild/global-styles.d.ts +0 -10
  135. package/src/tools/esbuild/global-styles.js +0 -74
  136. package/src/tools/esbuild/i18n-inliner-worker.d.ts +0 -42
  137. package/src/tools/esbuild/i18n-inliner-worker.js +0 -136
  138. package/src/tools/esbuild/i18n-inliner.d.ts +0 -44
  139. package/src/tools/esbuild/i18n-inliner.js +0 -150
  140. package/src/tools/esbuild/i18n-locale-plugin.d.ts +0 -22
  141. package/src/tools/esbuild/i18n-locale-plugin.js +0 -120
  142. package/src/tools/esbuild/index-html-generator.d.ts +0 -15
  143. package/src/tools/esbuild/index-html-generator.js +0 -81
  144. package/src/tools/esbuild/javascript-transformer-worker.d.ts +0 -19
  145. package/src/tools/esbuild/javascript-transformer-worker.js +0 -154
  146. package/src/tools/esbuild/javascript-transformer.d.ts +0 -54
  147. package/src/tools/esbuild/javascript-transformer.js +0 -147
  148. package/src/tools/esbuild/license-extractor.d.ts +0 -25
  149. package/src/tools/esbuild/license-extractor.js +0 -158
  150. package/src/tools/esbuild/load-result-cache.d.ts +0 -21
  151. package/src/tools/esbuild/load-result-cache.js +0 -75
  152. package/src/tools/esbuild/profiling.d.ts +0 -11
  153. package/src/tools/esbuild/profiling.js +0 -78
  154. package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +0 -18
  155. package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +0 -44
  156. package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +0 -17
  157. package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +0 -73
  158. package/src/tools/esbuild/stylesheets/bundle-options.d.ts +0 -35
  159. package/src/tools/esbuild/stylesheets/bundle-options.js +0 -64
  160. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +0 -25
  161. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +0 -57
  162. package/src/tools/esbuild/stylesheets/css-language.d.ts +0 -9
  163. package/src/tools/esbuild/stylesheets/css-language.js +0 -15
  164. package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +0 -18
  165. package/src/tools/esbuild/stylesheets/css-resource-plugin.js +0 -114
  166. package/src/tools/esbuild/stylesheets/less-language.d.ts +0 -9
  167. package/src/tools/esbuild/stylesheets/less-language.js +0 -155
  168. package/src/tools/esbuild/stylesheets/sass-language.d.ts +0 -10
  169. package/src/tools/esbuild/stylesheets/sass-language.js +0 -185
  170. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +0 -58
  171. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +0 -282
  172. package/src/tools/esbuild/utils.d.ts +0 -41
  173. package/src/tools/esbuild/utils.js +0 -378
  174. package/src/tools/esbuild/virtual-module-plugin.d.ts +0 -33
  175. package/src/tools/esbuild/virtual-module-plugin.js +0 -43
  176. package/src/tools/esbuild/watcher.d.ts +0 -25
  177. package/src/tools/esbuild/watcher.js +0 -118
  178. package/src/tools/sass/lexer.d.ts +0 -18
  179. package/src/tools/sass/lexer.js +0 -161
  180. package/src/tools/sass/rebasing-importer.d.ts +0 -101
  181. package/src/tools/sass/rebasing-importer.js +0 -334
  182. package/src/tools/sass/sass-service.d.ts +0 -72
  183. package/src/tools/sass/sass-service.js +0 -213
  184. package/src/tools/sass/worker.d.ts +0 -8
  185. package/src/tools/sass/worker.js +0 -192
  186. package/src/tools/vite/angular-memory-plugin.d.ts +0 -24
  187. package/src/tools/vite/angular-memory-plugin.js +0 -268
  188. package/src/tools/vite/i18n-locale-plugin.d.ts +0 -18
  189. package/src/tools/vite/i18n-locale-plugin.js +0 -55
  190. package/src/typings.d.ts +0 -21
  191. package/src/utils/bundle-calculator.d.ts +0 -44
  192. package/src/utils/bundle-calculator.js +0 -303
  193. package/src/utils/check-port.d.ts +0 -8
  194. package/src/utils/check-port.js +0 -58
  195. package/src/utils/delete-output-dir.d.ts +0 -11
  196. package/src/utils/delete-output-dir.js +0 -46
  197. package/src/utils/format-bytes.d.ts +0 -8
  198. package/src/utils/format-bytes.js +0 -22
  199. package/src/utils/i18n-options.d.ts +0 -33
  200. package/src/utils/i18n-options.js +0 -161
  201. package/src/utils/index-file/add-event-dispatch-contract.d.ts +0 -8
  202. package/src/utils/index-file/add-event-dispatch-contract.js +0 -28
  203. package/src/utils/index-file/augment-index-html.d.ts +0 -40
  204. package/src/utils/index-file/augment-index-html.js +0 -239
  205. package/src/utils/index-file/html-rewriting-stream.d.ts +0 -11
  206. package/src/utils/index-file/html-rewriting-stream.js +0 -28
  207. package/src/utils/index-file/index-html-generator.d.ts +0 -57
  208. package/src/utils/index-file/index-html-generator.js +0 -135
  209. package/src/utils/index-file/inline-critical-css.d.ts +0 -24
  210. package/src/utils/index-file/inline-critical-css.js +0 -179
  211. package/src/utils/index-file/inline-fonts.d.ts +0 -23
  212. package/src/utils/index-file/inline-fonts.js +0 -267
  213. package/src/utils/index-file/nonce.d.ts +0 -12
  214. package/src/utils/index-file/nonce.js +0 -55
  215. package/src/utils/load-proxy-config.d.ts +0 -8
  216. package/src/utils/load-proxy-config.js +0 -189
  217. package/src/utils/load-translations.d.ts +0 -16
  218. package/src/utils/load-translations.js +0 -84
  219. package/src/utils/postcss-configuration.d.ts +0 -17
  220. package/src/utils/postcss-configuration.js +0 -86
  221. package/src/utils/purge-cache.d.ts +0 -10
  222. package/src/utils/purge-cache.js +0 -40
  223. package/src/utils/resolve-assets.d.ts +0 -18
  224. package/src/utils/resolve-assets.js +0 -35
  225. package/src/utils/routes-extractor/extractor.d.ts +0 -15
  226. package/src/utils/routes-extractor/extractor.js +0 -97
  227. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +0 -18
  228. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -129
  229. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +0 -8
  230. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +0 -13
  231. package/src/utils/server-rendering/fetch-patch.d.ts +0 -8
  232. package/src/utils/server-rendering/fetch-patch.js +0 -66
  233. package/src/utils/server-rendering/load-esm-from-memory.d.ts +0 -10
  234. package/src/utils/server-rendering/load-esm-from-memory.js +0 -26
  235. package/src/utils/server-rendering/main-bundle-exports.d.ts +0 -27
  236. package/src/utils/server-rendering/main-bundle-exports.js +0 -9
  237. package/src/utils/server-rendering/prerender.d.ts +0 -23
  238. package/src/utils/server-rendering/prerender.js +0 -192
  239. package/src/utils/server-rendering/render-page.d.ts +0 -26
  240. package/src/utils/server-rendering/render-page.js +0 -110
  241. package/src/utils/server-rendering/render-worker.d.ts +0 -22
  242. package/src/utils/server-rendering/render-worker.js +0 -30
  243. package/src/utils/server-rendering/routes-extractor-worker.d.ts +0 -21
  244. package/src/utils/server-rendering/routes-extractor-worker.js +0 -53
  245. package/src/utils/service-worker.d.ts +0 -25
  246. package/src/utils/service-worker.js +0 -211
  247. package/src/utils/stats-table.d.ts +0 -20
  248. package/src/utils/stats-table.js +0 -205
  249. package/src/utils/supported-browsers.d.ts +0 -10
  250. package/src/utils/supported-browsers.js +0 -42
  251. package/src/utils/version.d.ts +0 -8
  252. package/src/utils/version.js +0 -59
@@ -1,121 +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.buildApplication = exports.buildApplicationInternal = void 0;
11
- const architect_1 = require("@angular-devkit/architect");
12
- const bundler_context_1 = require("../../tools/esbuild/bundler-context");
13
- const utils_1 = require("../../tools/esbuild/utils");
14
- const color_1 = require("../../utils/color");
15
- const purge_cache_1 = require("../../utils/purge-cache");
16
- const version_1 = require("../../utils/version");
17
- const build_action_1 = require("./build-action");
18
- const execute_build_1 = require("./execute-build");
19
- const options_1 = require("./options");
20
- async function* buildApplicationInternal(options,
21
- // TODO: Integrate abort signal support into builder system
22
- context, infrastructureSettings, extensions) {
23
- const { workspaceRoot, logger, target } = context;
24
- // Check Angular version.
25
- (0, version_1.assertCompatibleAngularVersion)(workspaceRoot);
26
- // Purge old build disk cache.
27
- await (0, purge_cache_1.purgeStaleBuildCache)(context);
28
- // Determine project name from builder context target
29
- const projectName = target?.project;
30
- if (!projectName) {
31
- yield { success: false, error: `The 'application' builder requires a target to be specified.` };
32
- return;
33
- }
34
- const normalizedOptions = await (0, options_1.normalizeOptions)(context, projectName, options, extensions);
35
- const writeToFileSystem = infrastructureSettings?.write ?? true;
36
- const writeServerBundles = writeToFileSystem && !!(normalizedOptions.ssrOptions && normalizedOptions.serverEntryPoint);
37
- if (writeServerBundles) {
38
- const { browser, server } = normalizedOptions.outputOptions;
39
- if (browser === '') {
40
- yield {
41
- success: false,
42
- error: `'outputPath.browser' cannot be configured to an empty string when SSR is enabled.`,
43
- };
44
- return;
45
- }
46
- if (browser === server) {
47
- yield {
48
- success: false,
49
- error: `'outputPath.browser' and 'outputPath.server' cannot be configured to the same value.`,
50
- };
51
- return;
52
- }
53
- }
54
- // Setup an abort controller with a builder teardown if no signal is present
55
- let signal = context.signal;
56
- if (!signal) {
57
- const controller = new AbortController();
58
- signal = controller.signal;
59
- context.addTeardown(() => controller.abort('builder-teardown'));
60
- }
61
- yield* (0, build_action_1.runEsBuildBuildAction)(async (rebuildState) => {
62
- const { prerenderOptions, outputOptions, jsonLogs } = normalizedOptions;
63
- const startTime = process.hrtime.bigint();
64
- const result = await (0, execute_build_1.executeBuild)(normalizedOptions, context, rebuildState);
65
- if (jsonLogs) {
66
- result.addLog(await (0, utils_1.createJsonBuildManifest)(result, normalizedOptions));
67
- }
68
- else {
69
- if (prerenderOptions) {
70
- const prerenderedRoutesLength = result.prerenderedRoutes.length;
71
- let prerenderMsg = `Prerendered ${prerenderedRoutesLength} static route`;
72
- prerenderMsg += prerenderedRoutesLength !== 1 ? 's.' : '.';
73
- result.addLog(color_1.colors.magenta(prerenderMsg));
74
- }
75
- const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
76
- const hasError = result.errors.length > 0;
77
- if (writeToFileSystem && !hasError) {
78
- result.addLog(`Output location: ${outputOptions.base}\n`);
79
- }
80
- result.addLog(`Application bundle generation ${hasError ? 'failed' : 'complete'}. [${buildTime.toFixed(3)} seconds]\n`);
81
- }
82
- return result;
83
- }, {
84
- watch: normalizedOptions.watch,
85
- preserveSymlinks: normalizedOptions.preserveSymlinks,
86
- poll: normalizedOptions.poll,
87
- deleteOutputPath: normalizedOptions.deleteOutputPath,
88
- cacheOptions: normalizedOptions.cacheOptions,
89
- outputOptions: normalizedOptions.outputOptions,
90
- verbose: normalizedOptions.verbose,
91
- projectRoot: normalizedOptions.projectRoot,
92
- workspaceRoot: normalizedOptions.workspaceRoot,
93
- progress: normalizedOptions.progress,
94
- clearScreen: normalizedOptions.clearScreen,
95
- colors: normalizedOptions.colors,
96
- jsonLogs: normalizedOptions.jsonLogs,
97
- writeToFileSystem,
98
- // For app-shell and SSG server files are not required by users.
99
- // Omit these when SSR is not enabled.
100
- writeToFileSystemFilter: writeServerBundles
101
- ? undefined
102
- : (file) => file.type !== bundler_context_1.BuildOutputFileType.Server,
103
- logger,
104
- signal,
105
- });
106
- }
107
- exports.buildApplicationInternal = buildApplicationInternal;
108
- function buildApplication(options, context, pluginsOrExtensions) {
109
- let extensions;
110
- if (pluginsOrExtensions && Array.isArray(pluginsOrExtensions)) {
111
- extensions = {
112
- codePlugins: pluginsOrExtensions,
113
- };
114
- }
115
- else {
116
- extensions = pluginsOrExtensions;
117
- }
118
- return buildApplicationInternal(options, context, undefined, extensions);
119
- }
120
- exports.buildApplication = buildApplication;
121
- exports.default = (0, architect_1.createBuilder)(buildApplication);
@@ -1,149 +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 { BuilderContext } from '@angular-devkit/architect';
9
- import type { Plugin } from 'esbuild';
10
- import { I18nOptions } from '../../utils/i18n-options';
11
- import { IndexHtmlTransform } from '../../utils/index-file/index-html-generator';
12
- import { Schema as ApplicationBuilderOptions, I18NTranslation, OutputPathClass } from './schema';
13
- export type NormalizedOutputOptions = Required<OutputPathClass>;
14
- export type NormalizedApplicationBuildOptions = Awaited<ReturnType<typeof normalizeOptions>>;
15
- export interface ApplicationBuilderExtensions {
16
- codePlugins?: Plugin[];
17
- indexHtmlTransformer?: IndexHtmlTransform;
18
- }
19
- /** Internal options hidden from builder schema but available when invoked programmatically. */
20
- interface InternalOptions {
21
- /**
22
- * Entry points to use for the compilation. Incompatible with `browser`, which must not be provided. May be relative or absolute paths.
23
- * If given a relative path, it is resolved relative to the current workspace and will generate an output at the same relative location
24
- * in the output directory. If given an absolute path, the output will be generated in the root of the output directory with the same base
25
- * name.
26
- */
27
- entryPoints?: Set<string>;
28
- /** File extension to use for the generated output files. */
29
- outExtension?: 'js' | 'mjs';
30
- /**
31
- * Indicates whether all node packages should be marked as external.
32
- * Currently used by the dev-server to support prebundling.
33
- */
34
- externalPackages?: boolean | {
35
- exclude: string[];
36
- };
37
- /**
38
- * Forces the output from the localize post-processing to not create nested directories per locale output.
39
- * This is only used by the development server which currently only supports a single locale per build.
40
- */
41
- forceI18nFlatOutput?: boolean;
42
- }
43
- /** Full set of options for `application` builder. */
44
- export type ApplicationBuilderInternalOptions = Omit<ApplicationBuilderOptions & InternalOptions, 'browser'> & {
45
- browser?: string;
46
- };
47
- /**
48
- * Normalize the user provided options by creating full paths for all path based options
49
- * and converting multi-form options into a single form that can be directly used
50
- * by the build process.
51
- *
52
- * @param context The context for current builder execution.
53
- * @param projectName The name of the project for the current execution.
54
- * @param options An object containing the options to use for the build.
55
- * @param plugins An optional array of programmatically supplied build plugins.
56
- * @returns An object containing normalized options required to perform the build.
57
- */
58
- export declare function normalizeOptions(context: BuilderContext, projectName: string, options: ApplicationBuilderInternalOptions, extensions?: ApplicationBuilderExtensions): Promise<{
59
- advancedOptimizations: boolean;
60
- allowedCommonJsDependencies: string[] | undefined;
61
- baseHref: string | undefined;
62
- cacheOptions: import("../../utils/normalize-cache").NormalizedCachedOptions;
63
- crossOrigin: import("./schema").CrossOrigin | undefined;
64
- deleteOutputPath: boolean | undefined;
65
- externalDependencies: string[] | undefined;
66
- extractLicenses: boolean | undefined;
67
- inlineStyleLanguage: string;
68
- jit: boolean;
69
- stats: boolean;
70
- polyfills: string[] | undefined;
71
- poll: number | undefined;
72
- progress: boolean;
73
- externalPackages: boolean | {
74
- exclude: string[];
75
- } | undefined;
76
- preserveSymlinks: boolean;
77
- stylePreprocessorOptions: import("./schema").StylePreprocessorOptions | undefined;
78
- subresourceIntegrity: boolean | undefined;
79
- serverEntryPoint: string | undefined;
80
- prerenderOptions: {
81
- discoverRoutes: boolean;
82
- routesFile: string | undefined;
83
- } | undefined;
84
- appShellOptions: {
85
- route: string;
86
- } | undefined;
87
- ssrOptions: {
88
- entry?: undefined;
89
- } | {
90
- entry: string | undefined;
91
- } | undefined;
92
- verbose: boolean | undefined;
93
- watch: boolean | undefined;
94
- workspaceRoot: string;
95
- entryPoints: Record<string, string>;
96
- optimizationOptions: import("../../utils").NormalizedOptimizationOptions;
97
- outputOptions: Required<OutputPathClass>;
98
- outExtension: "js" | "mjs" | undefined;
99
- sourcemapOptions: import("../..").SourceMapObject;
100
- tsconfig: string;
101
- projectRoot: string;
102
- assets: (import("../..").AssetPatternObject & {
103
- output: string;
104
- })[] | undefined;
105
- outputNames: {
106
- bundles: string;
107
- media: string;
108
- };
109
- fileReplacements: Record<string, string> | undefined;
110
- globalStyles: {
111
- name: string;
112
- files: string[];
113
- initial: boolean;
114
- }[];
115
- globalScripts: {
116
- name: string;
117
- files: string[];
118
- initial: boolean;
119
- }[];
120
- serviceWorker: string | undefined;
121
- indexHtmlOptions: {
122
- input: string;
123
- output: string;
124
- insertionOrder: [string, boolean][];
125
- transformer: IndexHtmlTransform | undefined;
126
- preloadInitial: boolean;
127
- } | undefined;
128
- tailwindConfiguration: {
129
- file: string;
130
- package: string;
131
- } | undefined;
132
- postcssConfiguration: import("../../utils/postcss-configuration").PostcssConfiguration | undefined;
133
- i18nOptions: I18nOptions & {
134
- duplicateTranslationBehavior?: I18NTranslation | undefined;
135
- missingTranslationBehavior?: I18NTranslation | undefined;
136
- };
137
- namedChunks: boolean | undefined;
138
- budgets: import("./schema").Budget[] | undefined;
139
- publicPath: string | undefined;
140
- plugins: Plugin[] | undefined;
141
- loaderExtensions: Record<string, "binary" | "file" | "text"> | undefined;
142
- jsonLogs: boolean;
143
- colors: boolean;
144
- clearScreen: boolean | undefined;
145
- define: {
146
- [key: string]: string;
147
- } | undefined;
148
- }>;
149
- export {};
@@ -1,369 +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.normalizeOptions = void 0;
14
- const node_fs_1 = require("node:fs");
15
- const promises_1 = require("node:fs/promises");
16
- const node_module_1 = require("node:module");
17
- const node_path_1 = __importDefault(require("node:path"));
18
- const utils_1 = require("../../utils");
19
- const color_1 = require("../../utils/color");
20
- const environment_options_1 = require("../../utils/environment-options");
21
- const i18n_options_1 = require("../../utils/i18n-options");
22
- const normalize_cache_1 = require("../../utils/normalize-cache");
23
- const postcss_configuration_1 = require("../../utils/postcss-configuration");
24
- const schema_1 = require("./schema");
25
- /**
26
- * Normalize the user provided options by creating full paths for all path based options
27
- * and converting multi-form options into a single form that can be directly used
28
- * by the build process.
29
- *
30
- * @param context The context for current builder execution.
31
- * @param projectName The name of the project for the current execution.
32
- * @param options An object containing the options to use for the build.
33
- * @param plugins An optional array of programmatically supplied build plugins.
34
- * @returns An object containing normalized options required to perform the build.
35
- */
36
- // eslint-disable-next-line max-lines-per-function
37
- async function normalizeOptions(context, projectName, options, extensions) {
38
- // If not explicitly set, default to the Node.js process argument
39
- const preserveSymlinks = options.preserveSymlinks ?? process.execArgv.includes('--preserve-symlinks');
40
- // Setup base paths based on workspace root and project information
41
- const workspaceRoot = preserveSymlinks
42
- ? context.workspaceRoot
43
- : // NOTE: promises.realpath should not be used here since it uses realpath.native which
44
- // can cause case conversion and other undesirable behavior on Windows systems.
45
- // ref: https://github.com/nodejs/node/issues/7726
46
- (0, node_fs_1.realpathSync)(context.workspaceRoot);
47
- const projectMetadata = await context.getProjectMetadata(projectName);
48
- const projectRoot = normalizeDirectoryPath(node_path_1.default.join(workspaceRoot, projectMetadata.root ?? ''));
49
- const projectSourceRoot = normalizeDirectoryPath(node_path_1.default.join(workspaceRoot, projectMetadata.sourceRoot ?? 'src'));
50
- // Gather persistent caching option and provide a project specific cache location
51
- const cacheOptions = (0, normalize_cache_1.normalizeCacheOptions)(projectMetadata, workspaceRoot);
52
- cacheOptions.path = node_path_1.default.join(cacheOptions.path, projectName);
53
- const i18nOptions = (0, i18n_options_1.createI18nOptions)(projectMetadata, options.localize);
54
- i18nOptions.duplicateTranslationBehavior = options.i18nDuplicateTranslation;
55
- i18nOptions.missingTranslationBehavior = options.i18nMissingTranslation;
56
- if (options.forceI18nFlatOutput) {
57
- i18nOptions.flatOutput = true;
58
- }
59
- const entryPoints = normalizeEntryPoints(workspaceRoot, options.browser, options.entryPoints);
60
- const tsconfig = node_path_1.default.join(workspaceRoot, options.tsConfig);
61
- const optimizationOptions = (0, utils_1.normalizeOptimization)(options.optimization);
62
- const sourcemapOptions = (0, utils_1.normalizeSourceMaps)(options.sourceMap ?? false);
63
- const assets = options.assets?.length
64
- ? (0, utils_1.normalizeAssetPatterns)(options.assets, workspaceRoot, projectRoot, projectSourceRoot)
65
- : undefined;
66
- const outputPath = options.outputPath;
67
- const outputOptions = {
68
- browser: 'browser',
69
- server: 'server',
70
- media: 'media',
71
- ...(typeof outputPath === 'string' ? undefined : outputPath),
72
- base: normalizeDirectoryPath(node_path_1.default.resolve(workspaceRoot, typeof outputPath === 'string' ? outputPath : outputPath.base)),
73
- };
74
- const outputNames = {
75
- bundles: options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Bundles
76
- ? '[name]-[hash]'
77
- : '[name]',
78
- media: outputOptions.media +
79
- (options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Media
80
- ? '/[name]-[hash]'
81
- : '/[name]'),
82
- };
83
- let fileReplacements;
84
- if (options.fileReplacements) {
85
- for (const replacement of options.fileReplacements) {
86
- const fileReplaceWith = node_path_1.default.join(workspaceRoot, replacement.with);
87
- try {
88
- await (0, promises_1.access)(fileReplaceWith, promises_1.constants.F_OK);
89
- }
90
- catch {
91
- throw new Error(`The ${fileReplaceWith} path in file replacements does not exist.`);
92
- }
93
- fileReplacements ??= {};
94
- fileReplacements[node_path_1.default.join(workspaceRoot, replacement.replace)] = fileReplaceWith;
95
- }
96
- }
97
- let loaderExtensions;
98
- if (options.loader) {
99
- for (const [extension, value] of Object.entries(options.loader)) {
100
- if (extension[0] !== '.' || /\.[cm]?[jt]sx?$/.test(extension)) {
101
- continue;
102
- }
103
- if (value !== 'text' && value !== 'binary' && value !== 'file' && value !== 'empty') {
104
- continue;
105
- }
106
- loaderExtensions ??= {};
107
- loaderExtensions[extension] = value;
108
- }
109
- }
110
- // A configuration file can exist in the project or workspace root
111
- const searchDirectories = await (0, postcss_configuration_1.generateSearchDirectories)([projectRoot, workspaceRoot]);
112
- const postcssConfiguration = await (0, postcss_configuration_1.loadPostcssConfiguration)(searchDirectories);
113
- // Skip tailwind configuration if postcss is customized
114
- const tailwindConfiguration = postcssConfiguration
115
- ? undefined
116
- : await getTailwindConfig(searchDirectories, workspaceRoot, context);
117
- let serverEntryPoint;
118
- if (options.server) {
119
- serverEntryPoint = node_path_1.default.join(workspaceRoot, options.server);
120
- }
121
- else if (options.server === '') {
122
- throw new Error('The "server" option cannot be an empty string.');
123
- }
124
- let prerenderOptions;
125
- if (options.prerender) {
126
- const { discoverRoutes = true, routesFile = undefined } = options.prerender === true ? {} : options.prerender;
127
- prerenderOptions = {
128
- discoverRoutes,
129
- routesFile: routesFile && node_path_1.default.join(workspaceRoot, routesFile),
130
- };
131
- }
132
- let ssrOptions;
133
- if (options.ssr === true) {
134
- ssrOptions = {};
135
- }
136
- else if (typeof options.ssr === 'object') {
137
- const { entry } = options.ssr;
138
- ssrOptions = {
139
- entry: entry && node_path_1.default.join(workspaceRoot, entry),
140
- };
141
- }
142
- let appShellOptions;
143
- if (options.appShell) {
144
- appShellOptions = {
145
- route: 'shell',
146
- };
147
- }
148
- const globalStyles = normalizeGlobalEntries(options.styles, 'styles');
149
- const globalScripts = normalizeGlobalEntries(options.scripts, 'scripts');
150
- let indexHtmlOptions;
151
- // index can never have a value of `true` but in the schema it's of type `boolean`.
152
- if (typeof options.index !== 'boolean') {
153
- let indexOutput;
154
- // The output file will be created within the configured output path
155
- if (typeof options.index === 'string') {
156
- /**
157
- * If SSR is activated, create a distinct entry file for the `index.html`.
158
- * This is necessary because numerous server/cloud providers automatically serve the `index.html` as a static file
159
- * if it exists (handling SSG).
160
- * For instance, accessing `foo.com/` would lead to `foo.com/index.html` being served instead of hitting the server.
161
- */
162
- const indexBaseName = node_path_1.default.basename(options.index);
163
- indexOutput = ssrOptions && indexBaseName === 'index.html' ? 'index.csr.html' : indexBaseName;
164
- }
165
- else {
166
- indexOutput = options.index.output || 'index.html';
167
- }
168
- indexHtmlOptions = {
169
- input: node_path_1.default.join(workspaceRoot, typeof options.index === 'string' ? options.index : options.index.input),
170
- output: indexOutput,
171
- insertionOrder: [
172
- ['polyfills', true],
173
- ...globalStyles.filter((s) => s.initial).map((s) => [s.name, false]),
174
- ...globalScripts.filter((s) => s.initial).map((s) => [s.name, false]),
175
- ['main', true],
176
- // [name, esm]
177
- ],
178
- transformer: extensions?.indexHtmlTransformer,
179
- // Preload initial defaults to true
180
- preloadInitial: typeof options.index !== 'object' || (options.index.preloadInitial ?? true),
181
- };
182
- }
183
- if (appShellOptions || ssrOptions || prerenderOptions) {
184
- if (!serverEntryPoint) {
185
- throw new Error('The "server" option is required when enabling "ssr", "prerender" or "app-shell".');
186
- }
187
- if (!indexHtmlOptions) {
188
- throw new Error('The "index" option cannot be set to false when enabling "ssr", "prerender" or "app-shell".');
189
- }
190
- }
191
- // Initial options to keep
192
- const { allowedCommonJsDependencies, aot, baseHref, crossOrigin, externalDependencies, extractLicenses, inlineStyleLanguage = 'css', outExtension, serviceWorker, poll, polyfills, statsJson, stylePreprocessorOptions, subresourceIntegrity, verbose, watch, progress = true, externalPackages, deleteOutputPath, namedChunks, budgets, deployUrl, clearScreen, define, } = options;
193
- // Return all the normalized options
194
- return {
195
- advancedOptimizations: !!aot && optimizationOptions.scripts,
196
- allowedCommonJsDependencies,
197
- baseHref,
198
- cacheOptions,
199
- crossOrigin,
200
- deleteOutputPath,
201
- externalDependencies,
202
- extractLicenses,
203
- inlineStyleLanguage,
204
- jit: !aot,
205
- stats: !!statsJson,
206
- polyfills: polyfills === undefined || Array.isArray(polyfills) ? polyfills : [polyfills],
207
- poll,
208
- progress,
209
- externalPackages,
210
- preserveSymlinks,
211
- stylePreprocessorOptions,
212
- subresourceIntegrity,
213
- serverEntryPoint,
214
- prerenderOptions,
215
- appShellOptions,
216
- ssrOptions,
217
- verbose,
218
- watch,
219
- workspaceRoot,
220
- entryPoints,
221
- optimizationOptions,
222
- outputOptions,
223
- outExtension,
224
- sourcemapOptions,
225
- tsconfig,
226
- projectRoot,
227
- assets,
228
- outputNames,
229
- fileReplacements,
230
- globalStyles,
231
- globalScripts,
232
- serviceWorker: serviceWorker
233
- ? node_path_1.default.join(workspaceRoot, typeof serviceWorker === 'string' ? serviceWorker : 'src/ngsw-config.json')
234
- : undefined,
235
- indexHtmlOptions,
236
- tailwindConfiguration,
237
- postcssConfiguration,
238
- i18nOptions,
239
- namedChunks,
240
- budgets: budgets?.length ? budgets : undefined,
241
- publicPath: deployUrl,
242
- plugins: extensions?.codePlugins?.length ? extensions?.codePlugins : undefined,
243
- loaderExtensions,
244
- jsonLogs: environment_options_1.useJSONBuildLogs,
245
- colors: color_1.colors.enabled,
246
- clearScreen,
247
- define,
248
- };
249
- }
250
- exports.normalizeOptions = normalizeOptions;
251
- async function getTailwindConfig(searchDirectories, workspaceRoot, context) {
252
- const tailwindConfigurationPath = (0, postcss_configuration_1.findTailwindConfiguration)(searchDirectories);
253
- if (!tailwindConfigurationPath) {
254
- return undefined;
255
- }
256
- // Create a node resolver from the configuration file
257
- const resolver = (0, node_module_1.createRequire)(tailwindConfigurationPath);
258
- try {
259
- return {
260
- file: tailwindConfigurationPath,
261
- package: resolver.resolve('tailwindcss'),
262
- };
263
- }
264
- catch {
265
- const relativeTailwindConfigPath = node_path_1.default.relative(workspaceRoot, tailwindConfigurationPath);
266
- context.logger.warn(`Tailwind CSS configuration file found (${relativeTailwindConfigPath})` +
267
- ` but the 'tailwindcss' package is not installed.` +
268
- ` To enable Tailwind CSS, please install the 'tailwindcss' package.`);
269
- }
270
- return undefined;
271
- }
272
- /**
273
- * Normalize entry point options. To maintain compatibility with the legacy browser builder, we need a single `browser`
274
- * option which defines a single entry point. However, we also want to support multiple entry points as an internal option.
275
- * The two options are mutually exclusive and if `browser` is provided it will be used as the sole entry point.
276
- * If `entryPoints` are provided, they will be used as the set of entry points.
277
- *
278
- * @param workspaceRoot Path to the root of the Angular workspace.
279
- * @param browser The `browser` option pointing at the application entry point. While required per the schema file, it may be omitted by
280
- * programmatic usages of `browser-esbuild`.
281
- * @param entryPoints Set of entry points to use if provided.
282
- * @returns An object mapping entry point names to their file paths.
283
- */
284
- function normalizeEntryPoints(workspaceRoot, browser, entryPoints = new Set()) {
285
- if (browser === '') {
286
- throw new Error('`browser` option cannot be an empty string.');
287
- }
288
- // `browser` and `entryPoints` are mutually exclusive.
289
- if (browser && entryPoints.size > 0) {
290
- throw new Error('Only one of `browser` or `entryPoints` may be provided.');
291
- }
292
- if (!browser && entryPoints.size === 0) {
293
- // Schema should normally reject this case, but programmatic usages of the builder might make this mistake.
294
- throw new Error('Either `browser` or at least one `entryPoints` value must be provided.');
295
- }
296
- // Schema types force `browser` to always be provided, but it may be omitted when the builder is invoked programmatically.
297
- if (browser) {
298
- // Use `browser` alone.
299
- return { 'main': node_path_1.default.join(workspaceRoot, browser) };
300
- }
301
- else {
302
- // Use `entryPoints` alone.
303
- const entryPointPaths = {};
304
- for (const entryPoint of entryPoints) {
305
- const parsedEntryPoint = node_path_1.default.parse(entryPoint);
306
- // Use the input file path without an extension as the "name" of the entry point dictating its output location.
307
- // Relative entry points are generated at the same relative path in the output directory.
308
- // Absolute entry points are always generated with the same file name in the root of the output directory. This includes absolute
309
- // paths pointing at files actually within the workspace root.
310
- const entryPointName = node_path_1.default.isAbsolute(entryPoint)
311
- ? parsedEntryPoint.name
312
- : node_path_1.default.join(parsedEntryPoint.dir, parsedEntryPoint.name);
313
- // Get the full file path to a relative entry point input. Leave bare specifiers alone so they are resolved as modules.
314
- const isRelativePath = entryPoint.startsWith('.');
315
- const entryPointPath = isRelativePath ? node_path_1.default.join(workspaceRoot, entryPoint) : entryPoint;
316
- // Check for conflicts with previous entry points.
317
- const existingEntryPointPath = entryPointPaths[entryPointName];
318
- if (existingEntryPointPath) {
319
- throw new Error(`\`${existingEntryPointPath}\` and \`${entryPointPath}\` both output to the same location \`${entryPointName}\`.` +
320
- ' Rename or move one of the files to fix the conflict.');
321
- }
322
- entryPointPaths[entryPointName] = entryPointPath;
323
- }
324
- return entryPointPaths;
325
- }
326
- }
327
- /**
328
- * Normalize a directory path string.
329
- * Currently only removes a trailing slash if present.
330
- * @param path A path string.
331
- * @returns A normalized path string.
332
- */
333
- function normalizeDirectoryPath(path) {
334
- const last = path[path.length - 1];
335
- if (last === '/' || last === '\\') {
336
- return path.slice(0, -1);
337
- }
338
- return path;
339
- }
340
- function normalizeGlobalEntries(rawEntries, defaultName) {
341
- if (!rawEntries?.length) {
342
- return [];
343
- }
344
- const bundles = new Map();
345
- for (const rawEntry of rawEntries) {
346
- let entry;
347
- if (typeof rawEntry === 'string') {
348
- // string entries use default bundle name and inject values
349
- entry = { input: rawEntry };
350
- }
351
- else {
352
- entry = rawEntry;
353
- }
354
- const { bundleName, input, inject = true } = entry;
355
- // Non-injected entries default to the file name
356
- const name = bundleName || (inject ? defaultName : node_path_1.default.basename(input, node_path_1.default.extname(input)));
357
- const existing = bundles.get(name);
358
- if (!existing) {
359
- bundles.set(name, { name, files: [input], initial: inject });
360
- continue;
361
- }
362
- if (existing.initial !== inject) {
363
- throw new Error(`The "${name}" bundle is mixing injected and non-injected entries. ` +
364
- 'Verify that the project options are correct.');
365
- }
366
- existing.files.push(input);
367
- }
368
- return [...bundles.values()];
369
- }