@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,129 +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.load = exports.resolve = exports.initialize = void 0;
14
- const node_assert_1 = __importDefault(require("node:assert"));
15
- const node_crypto_1 = require("node:crypto");
16
- const node_path_1 = require("node:path");
17
- const node_url_1 = require("node:url");
18
- const url_1 = require("url");
19
- const javascript_transformer_1 = require("../../../tools/esbuild/javascript-transformer");
20
- /**
21
- * Node.js ESM loader to redirect imports to in memory files.
22
- * @see: https://nodejs.org/api/esm.html#loaders for more information about loaders.
23
- */
24
- const MEMORY_URL_SCHEME = 'memory://';
25
- let memoryVirtualRootUrl;
26
- let outputFiles;
27
- const javascriptTransformer = new javascript_transformer_1.JavaScriptTransformer(
28
- // Always enable JIT linking to support applications built with and without AOT.
29
- // In a development environment the additional scope information does not
30
- // have a negative effect unlike production where final output size is relevant.
31
- { sourcemap: true, jit: true }, 1);
32
- function initialize(data) {
33
- // This path does not actually exist but is used to overlay the in memory files with the
34
- // actual filesystem for resolution purposes.
35
- // A custom URL schema (such as `memory://`) cannot be used for the resolve output because
36
- // the in-memory files may use `import.meta.url` in ways that assume a file URL.
37
- // `createRequire` is one example of this usage.
38
- memoryVirtualRootUrl = (0, node_url_1.pathToFileURL)((0, node_path_1.join)(data.workspaceRoot, `.angular/prerender-root/${(0, node_crypto_1.randomUUID)()}/`)).href;
39
- outputFiles = data.outputFiles;
40
- }
41
- exports.initialize = initialize;
42
- function resolve(specifier, context, nextResolve) {
43
- // In-memory files loaded from external code will contain a memory scheme
44
- if (specifier.startsWith(MEMORY_URL_SCHEME)) {
45
- let memoryUrl;
46
- try {
47
- memoryUrl = new URL(specifier);
48
- }
49
- catch {
50
- node_assert_1.default.fail('External code attempted to use malformed memory scheme: ' + specifier);
51
- }
52
- // Resolve with a URL based from the virtual filesystem root
53
- return {
54
- format: 'module',
55
- shortCircuit: true,
56
- url: new URL(memoryUrl.pathname.slice(1), memoryVirtualRootUrl).href,
57
- };
58
- }
59
- // Use next/default resolve if the parent is not from the virtual root
60
- if (!context.parentURL?.startsWith(memoryVirtualRootUrl)) {
61
- return nextResolve(specifier, context);
62
- }
63
- // Check for `./` and `../` relative specifiers
64
- const isRelative = specifier[0] === '.' &&
65
- (specifier[1] === '/' || (specifier[1] === '.' && specifier[2] === '/'));
66
- // Relative specifiers from memory file should be based from the parent memory location
67
- if (isRelative) {
68
- let specifierUrl;
69
- try {
70
- specifierUrl = new URL(specifier, context.parentURL);
71
- }
72
- catch { }
73
- if (specifierUrl?.pathname &&
74
- Object.hasOwn(outputFiles, specifierUrl.href.slice(memoryVirtualRootUrl.length))) {
75
- return {
76
- format: 'module',
77
- shortCircuit: true,
78
- url: specifierUrl.href,
79
- };
80
- }
81
- node_assert_1.default.fail(`In-memory ESM relative file should always exist: '${context.parentURL}' --> '${specifier}'`);
82
- }
83
- // Update the parent URL to allow for module resolution for the workspace.
84
- // This handles bare specifiers (npm packages) and absolute paths.
85
- // Defer to the next hook in the chain, which would be the
86
- // Node.js default resolve if this is the last user-specified loader.
87
- return nextResolve(specifier, {
88
- ...context,
89
- parentURL: new URL('index.js', memoryVirtualRootUrl).href,
90
- });
91
- }
92
- exports.resolve = resolve;
93
- async function load(url, context, nextLoad) {
94
- const { format } = context;
95
- // Load the file from memory if the URL is based in the virtual root
96
- if (url.startsWith(memoryVirtualRootUrl)) {
97
- const source = outputFiles[url.slice(memoryVirtualRootUrl.length)];
98
- (0, node_assert_1.default)(source !== undefined, 'Resolved in-memory ESM file should always exist: ' + url);
99
- // In-memory files have already been transformer during bundling and can be returned directly
100
- return {
101
- format,
102
- shortCircuit: true,
103
- source,
104
- };
105
- }
106
- // Only module files potentially require transformation. Angular libraries that would
107
- // need linking are ESM only.
108
- if (format === 'module' && isFileProtocol(url)) {
109
- const filePath = (0, url_1.fileURLToPath)(url);
110
- const source = await javascriptTransformer.transformFile(filePath);
111
- return {
112
- format,
113
- shortCircuit: true,
114
- source,
115
- };
116
- }
117
- // Let Node.js handle all other URLs.
118
- return nextLoad(url);
119
- }
120
- exports.load = load;
121
- function isFileProtocol(url) {
122
- return url.startsWith('file://');
123
- }
124
- function handleProcessExit() {
125
- void javascriptTransformer.close();
126
- }
127
- process.once('exit', handleProcessExit);
128
- process.once('SIGINT', handleProcessExit);
129
- process.once('uncaughtException', handleProcessExit);
@@ -1,8 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- export {};
@@ -1,13 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const node_module_1 = require("node:module");
11
- const node_url_1 = require("node:url");
12
- const node_worker_threads_1 = require("node:worker_threads");
13
- (0, node_module_1.register)('./loader-hooks.js', { parentURL: (0, node_url_1.pathToFileURL)(__filename), data: node_worker_threads_1.workerData });
@@ -1,8 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- export declare function patchFetchToLoadInMemoryAssets(): void;
@@ -1,66 +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.patchFetchToLoadInMemoryAssets = void 0;
11
- const mrmime_1 = require("mrmime");
12
- const promises_1 = require("node:fs/promises");
13
- const node_path_1 = require("node:path");
14
- const node_worker_threads_1 = require("node:worker_threads");
15
- const undici_1 = require("undici");
16
- /**
17
- * This is passed as workerData when setting up the worker via the `piscina` package.
18
- */
19
- const { assetFiles } = node_worker_threads_1.workerData;
20
- const assetsCache = new Map();
21
- const RESOLVE_PROTOCOL = 'resolve:';
22
- function patchFetchToLoadInMemoryAssets() {
23
- const global = globalThis;
24
- const originalFetch = global.fetch;
25
- const patchedFetch = async (input, init) => {
26
- let url;
27
- if (input instanceof URL) {
28
- url = input;
29
- }
30
- else if (typeof input === 'string') {
31
- url = new URL(input, RESOLVE_PROTOCOL + '//');
32
- }
33
- else if (typeof input === 'object' && 'url' in input) {
34
- url = new URL(input.url, RESOLVE_PROTOCOL + '//');
35
- }
36
- else {
37
- return originalFetch(input, init);
38
- }
39
- const { pathname, protocol } = url;
40
- if (protocol !== RESOLVE_PROTOCOL || !assetFiles[pathname]) {
41
- // Only handle relative requests or files that are in assets.
42
- return originalFetch(input, init);
43
- }
44
- const cachedAsset = assetsCache.get(pathname);
45
- if (cachedAsset) {
46
- const { content, headers } = cachedAsset;
47
- return new undici_1.Response(content, {
48
- headers,
49
- });
50
- }
51
- const extension = (0, node_path_1.extname)(pathname);
52
- const mimeType = (0, mrmime_1.lookup)(extension);
53
- const content = await (0, promises_1.readFile)(assetFiles[pathname]);
54
- const headers = mimeType
55
- ? {
56
- 'Content-Type': mimeType,
57
- }
58
- : undefined;
59
- assetsCache.set(pathname, { headers, content });
60
- return new undici_1.Response(content, {
61
- headers,
62
- });
63
- };
64
- global.fetch = patchedFetch;
65
- }
66
- exports.patchFetchToLoadInMemoryAssets = patchFetchToLoadInMemoryAssets;
@@ -1,10 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { MainServerBundleExports, RenderUtilsServerBundleExports } from './main-bundle-exports';
9
- export declare function loadEsmModuleFromMemory(path: './main.server.mjs'): Promise<MainServerBundleExports>;
10
- export declare function loadEsmModuleFromMemory(path: './render-utils.server.mjs'): Promise<RenderUtilsServerBundleExports>;
@@ -1,26 +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.loadEsmModuleFromMemory = void 0;
11
- const error_1 = require("../error");
12
- const load_esm_1 = require("../load-esm");
13
- function loadEsmModuleFromMemory(path) {
14
- return (0, load_esm_1.loadEsmModule)(new URL(path, 'memory://')).catch((e) => {
15
- (0, error_1.assertIsError)(e);
16
- // While the error is an 'instanceof Error', it is extended with non transferable properties
17
- // and cannot be transferred from a worker when using `--import`. This results in the error object
18
- // displaying as '[Object object]' when read outside of the worker. Therefore, we reconstruct the error message here.
19
- const error = new Error(e.message);
20
- error.stack = e.stack;
21
- error.name = e.name;
22
- error.code = e.code;
23
- throw error;
24
- });
25
- }
26
- exports.loadEsmModuleFromMemory = loadEsmModuleFromMemory;
@@ -1,27 +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 { ApplicationRef, Type, ɵConsole } from '@angular/core';
9
- import type { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';
10
- import type { extractRoutes } from '../routes-extractor/extractor';
11
- export interface MainServerBundleExports {
12
- /** Standalone application bootstrapping function. */
13
- default: (() => Promise<ApplicationRef>) | Type<unknown>;
14
- }
15
- export interface RenderUtilsServerBundleExports {
16
- /** An internal token that allows providing extra information about the server context. */
17
- ɵSERVER_CONTEXT: typeof ɵSERVER_CONTEXT;
18
- /** Render an NgModule application. */
19
- renderModule: typeof renderModule;
20
- /** Method to render a standalone application. */
21
- renderApplication: typeof renderApplication;
22
- /** Method to extract routes from the router config. */
23
- extractRoutes: typeof extractRoutes;
24
- ɵresetCompiledComponents?: () => void;
25
- /** Angular Console token/class. */
26
- ɵConsole: typeof ɵConsole;
27
- }
@@ -1,9 +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 });
@@ -1,23 +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 { BuildOutputFile } from '../../tools/esbuild/bundler-context';
9
- import { BuildOutputAsset } from '../../tools/esbuild/bundler-execution-result';
10
- interface PrerenderOptions {
11
- routesFile?: string;
12
- discoverRoutes?: boolean;
13
- }
14
- interface AppShellOptions {
15
- route?: string;
16
- }
17
- export declare function prerenderPages(workspaceRoot: string, appShellOptions: AppShellOptions | undefined, prerenderOptions: PrerenderOptions | undefined, outputFiles: Readonly<BuildOutputFile[]>, assets: Readonly<BuildOutputAsset[]>, document: string, sourcemap?: boolean, inlineCriticalCss?: boolean, maxThreads?: number, verbose?: boolean): Promise<{
18
- output: Record<string, string>;
19
- warnings: string[];
20
- errors: string[];
21
- prerenderedRoutes: Set<string>;
22
- }>;
23
- export {};
@@ -1,192 +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.prerenderPages = void 0;
14
- const promises_1 = require("node:fs/promises");
15
- const node_path_1 = require("node:path");
16
- const node_url_1 = require("node:url");
17
- const piscina_1 = __importDefault(require("piscina"));
18
- const bundler_context_1 = require("../../tools/esbuild/bundler-context");
19
- async function prerenderPages(workspaceRoot, appShellOptions = {}, prerenderOptions = {}, outputFiles, assets, document, sourcemap = false, inlineCriticalCss = false, maxThreads = 1, verbose = false) {
20
- const outputFilesForWorker = {};
21
- const serverBundlesSourceMaps = new Map();
22
- const warnings = [];
23
- const errors = [];
24
- for (const { text, path, type } of outputFiles) {
25
- const fileExt = (0, node_path_1.extname)(path);
26
- if (type === bundler_context_1.BuildOutputFileType.Server && fileExt === '.map') {
27
- serverBundlesSourceMaps.set(path.slice(0, -4), text);
28
- }
29
- else if (type === bundler_context_1.BuildOutputFileType.Server || // Contains the server runnable application code
30
- (type === bundler_context_1.BuildOutputFileType.Browser && fileExt === '.css') // Global styles for critical CSS inlining.
31
- ) {
32
- outputFilesForWorker[path] = text;
33
- }
34
- }
35
- // Inline sourcemap into JS file. This is needed to make Node.js resolve sourcemaps
36
- // when using `--enable-source-maps` when using in memory files.
37
- for (const [filePath, map] of serverBundlesSourceMaps) {
38
- const jsContent = outputFilesForWorker[filePath];
39
- if (jsContent) {
40
- outputFilesForWorker[filePath] =
41
- jsContent +
42
- `\n//# sourceMappingURL=` +
43
- `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
44
- }
45
- }
46
- serverBundlesSourceMaps.clear();
47
- const assetsReversed = {};
48
- for (const { source, destination } of assets) {
49
- assetsReversed[addLeadingSlash(destination.replace(/\\/g, node_path_1.posix.sep))] = source;
50
- }
51
- // Get routes to prerender
52
- const { routes: allRoutes, warnings: routesWarnings } = await getAllRoutes(workspaceRoot, outputFilesForWorker, assetsReversed, document, appShellOptions, prerenderOptions, sourcemap, verbose);
53
- if (routesWarnings?.length) {
54
- warnings.push(...routesWarnings);
55
- }
56
- if (allRoutes.size < 1) {
57
- return {
58
- errors,
59
- warnings,
60
- output: {},
61
- prerenderedRoutes: allRoutes,
62
- };
63
- }
64
- // Render routes
65
- const { warnings: renderingWarnings, errors: renderingErrors, output, } = await renderPages(sourcemap, allRoutes, maxThreads, workspaceRoot, outputFilesForWorker, assetsReversed, inlineCriticalCss, document, appShellOptions);
66
- errors.push(...renderingErrors);
67
- warnings.push(...renderingWarnings);
68
- return {
69
- errors,
70
- warnings,
71
- output,
72
- prerenderedRoutes: allRoutes,
73
- };
74
- }
75
- exports.prerenderPages = prerenderPages;
76
- class RoutesSet extends Set {
77
- add(value) {
78
- return super.add(addLeadingSlash(value));
79
- }
80
- }
81
- async function renderPages(sourcemap, allRoutes, maxThreads, workspaceRoot, outputFilesForWorker, assetFilesForWorker, inlineCriticalCss, document, appShellOptions) {
82
- const output = {};
83
- const warnings = [];
84
- const errors = [];
85
- const workerExecArgv = [
86
- '--import',
87
- // Loader cannot be an absolute path on Windows.
88
- (0, node_url_1.pathToFileURL)((0, node_path_1.join)(__dirname, 'esm-in-memory-loader/register-hooks.js')).href,
89
- ];
90
- if (sourcemap) {
91
- workerExecArgv.push('--enable-source-maps');
92
- }
93
- const renderWorker = new piscina_1.default({
94
- filename: require.resolve('./render-worker'),
95
- maxThreads: Math.min(allRoutes.size, maxThreads),
96
- workerData: {
97
- workspaceRoot,
98
- outputFiles: outputFilesForWorker,
99
- assetFiles: assetFilesForWorker,
100
- inlineCriticalCss,
101
- document,
102
- },
103
- execArgv: workerExecArgv,
104
- recordTiming: false,
105
- });
106
- try {
107
- const renderingPromises = [];
108
- const appShellRoute = appShellOptions.route && addLeadingSlash(appShellOptions.route);
109
- for (const route of allRoutes) {
110
- const isAppShellRoute = appShellRoute === route;
111
- const serverContext = isAppShellRoute ? 'app-shell' : 'ssg';
112
- const render = renderWorker.run({ route, serverContext });
113
- const renderResult = render.then(({ content, warnings, errors }) => {
114
- if (content !== undefined) {
115
- const outPath = isAppShellRoute
116
- ? 'index.html'
117
- : node_path_1.posix.join(removeLeadingSlash(route), 'index.html');
118
- output[outPath] = content;
119
- }
120
- if (warnings) {
121
- warnings.push(...warnings);
122
- }
123
- if (errors) {
124
- errors.push(...errors);
125
- }
126
- });
127
- renderingPromises.push(renderResult);
128
- }
129
- await Promise.all(renderingPromises);
130
- }
131
- finally {
132
- void renderWorker.destroy();
133
- }
134
- return {
135
- errors,
136
- warnings,
137
- output,
138
- };
139
- }
140
- async function getAllRoutes(workspaceRoot, outputFilesForWorker, assetFilesForWorker, document, appShellOptions, prerenderOptions, sourcemap, verbose) {
141
- const { routesFile, discoverRoutes } = prerenderOptions;
142
- const routes = new RoutesSet();
143
- const { route: appShellRoute } = appShellOptions;
144
- if (appShellRoute !== undefined) {
145
- routes.add(appShellRoute);
146
- }
147
- if (routesFile) {
148
- const routesFromFile = (await (0, promises_1.readFile)(routesFile, 'utf8')).split(/\r?\n/);
149
- for (const route of routesFromFile) {
150
- routes.add(route.trim());
151
- }
152
- }
153
- if (!discoverRoutes) {
154
- return { routes };
155
- }
156
- const workerExecArgv = [
157
- '--import',
158
- // Loader cannot be an absolute path on Windows.
159
- (0, node_url_1.pathToFileURL)((0, node_path_1.join)(__dirname, 'esm-in-memory-loader/register-hooks.js')).href,
160
- ];
161
- if (sourcemap) {
162
- workerExecArgv.push('--enable-source-maps');
163
- }
164
- const renderWorker = new piscina_1.default({
165
- filename: require.resolve('./routes-extractor-worker'),
166
- maxThreads: 1,
167
- workerData: {
168
- workspaceRoot,
169
- outputFiles: outputFilesForWorker,
170
- assetFiles: assetFilesForWorker,
171
- document,
172
- verbose,
173
- },
174
- execArgv: workerExecArgv,
175
- recordTiming: false,
176
- });
177
- const { routes: extractedRoutes, warnings } = await renderWorker
178
- .run({})
179
- .finally(() => {
180
- void renderWorker.destroy();
181
- });
182
- for (const route of extractedRoutes) {
183
- routes.add(route);
184
- }
185
- return { routes, warnings };
186
- }
187
- function addLeadingSlash(value) {
188
- return value.charAt(0) === '/' ? value : '/' + value;
189
- }
190
- function removeLeadingSlash(value) {
191
- return value.charAt(0) === '/' ? value.slice(1) : value;
192
- }
@@ -1,26 +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 { MainServerBundleExports, RenderUtilsServerBundleExports } from './main-bundle-exports';
9
- export interface RenderOptions {
10
- route: string;
11
- serverContext: ServerContext;
12
- outputFiles: Record<string, string>;
13
- document: string;
14
- inlineCriticalCss?: boolean;
15
- loadBundle?: ((path: './main.server.mjs') => Promise<MainServerBundleExports>) & ((path: './render-utils.server.mjs') => Promise<RenderUtilsServerBundleExports>);
16
- }
17
- export interface RenderResult {
18
- errors?: string[];
19
- warnings?: string[];
20
- content?: string;
21
- }
22
- export type ServerContext = 'app-shell' | 'ssg' | 'ssr';
23
- /**
24
- * Renders each route in routes and writes them to <outputPath>/<route>/index.html.
25
- */
26
- export declare function renderPage({ route, serverContext, document, inlineCriticalCss, outputFiles, loadBundle, }: RenderOptions): Promise<RenderResult>;
@@ -1,110 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
32
- var __importDefault = (this && this.__importDefault) || function (mod) {
33
- return (mod && mod.__esModule) ? mod : { "default": mod };
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.renderPage = void 0;
37
- const node_assert_1 = __importDefault(require("node:assert"));
38
- const node_path_1 = require("node:path");
39
- const load_esm_from_memory_1 = require("./load-esm-from-memory");
40
- /**
41
- * Renders each route in routes and writes them to <outputPath>/<route>/index.html.
42
- */
43
- async function renderPage({ route, serverContext, document, inlineCriticalCss, outputFiles, loadBundle = load_esm_from_memory_1.loadEsmModuleFromMemory, }) {
44
- const { default: bootstrapAppFnOrModule } = await loadBundle('./main.server.mjs');
45
- const { ɵSERVER_CONTEXT, renderModule, renderApplication, ɵresetCompiledComponents, ɵConsole } = await loadBundle('./render-utils.server.mjs');
46
- // Need to clean up GENERATED_COMP_IDS map in `@angular/core`.
47
- // Otherwise an incorrect component ID generation collision detected warning will be displayed in development.
48
- // See: https://github.com/angular/angular-cli/issues/25924
49
- ɵresetCompiledComponents?.();
50
- const platformProviders = [
51
- {
52
- provide: ɵSERVER_CONTEXT,
53
- useValue: serverContext,
54
- },
55
- {
56
- provide: ɵConsole,
57
- /** An Angular Console Provider that does not print a set of predefined logs. */
58
- useFactory: () => {
59
- class Console extends ɵConsole {
60
- ignoredLogs = new Set(['Angular is running in development mode.']);
61
- log(message) {
62
- if (!this.ignoredLogs.has(message)) {
63
- super.log(message);
64
- }
65
- }
66
- }
67
- return new Console();
68
- },
69
- },
70
- ];
71
- let html;
72
- (0, node_assert_1.default)(bootstrapAppFnOrModule, 'The file "./main.server.mjs" does not have a default export for an AppServerModule or a bootstrapping function.');
73
- if (isBootstrapFn(bootstrapAppFnOrModule)) {
74
- html = await renderApplication(bootstrapAppFnOrModule, {
75
- document,
76
- url: route,
77
- platformProviders,
78
- });
79
- }
80
- else {
81
- html = await renderModule(bootstrapAppFnOrModule, {
82
- document,
83
- url: route,
84
- extraProviders: platformProviders,
85
- });
86
- }
87
- if (inlineCriticalCss) {
88
- const { InlineCriticalCssProcessor } = await Promise.resolve().then(() => __importStar(require('../../utils/index-file/inline-critical-css')));
89
- const inlineCriticalCssProcessor = new InlineCriticalCssProcessor({
90
- minify: false, // CSS has already been minified during the build.
91
- readAsset: async (filePath) => {
92
- filePath = (0, node_path_1.basename)(filePath);
93
- const content = outputFiles[filePath];
94
- if (content === undefined) {
95
- throw new Error(`Output file does not exist: ${filePath}`);
96
- }
97
- return content;
98
- },
99
- });
100
- return inlineCriticalCssProcessor.process(html, { outputPath: '' });
101
- }
102
- return {
103
- content: html,
104
- };
105
- }
106
- exports.renderPage = renderPage;
107
- function isBootstrapFn(value) {
108
- // We can differentiate between a module and a bootstrap function by reading compiler-generated `ɵmod` static property:
109
- return typeof value === 'function' && !('ɵmod' in value);
110
- }