@angular/build 18.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/builders.json +14 -0
  4. package/package.json +87 -0
  5. package/src/builders/application/build-action.d.ts +33 -0
  6. package/src/builders/application/build-action.js +183 -0
  7. package/src/builders/application/execute-build.d.ts +11 -0
  8. package/src/builders/application/execute-build.js +125 -0
  9. package/src/builders/application/execute-post-bundle.d.ts +25 -0
  10. package/src/builders/application/execute-post-bundle.js +93 -0
  11. package/src/builders/application/i18n.d.ts +29 -0
  12. package/src/builders/application/i18n.js +128 -0
  13. package/src/builders/application/index.d.ts +57 -0
  14. package/src/builders/application/index.js +121 -0
  15. package/src/builders/application/options.d.ts +149 -0
  16. package/src/builders/application/options.js +369 -0
  17. package/src/builders/application/schema.d.ts +512 -0
  18. package/src/builders/application/schema.js +58 -0
  19. package/src/builders/application/schema.json +635 -0
  20. package/src/builders/application/setup-bundling.d.ts +19 -0
  21. package/src/builders/application/setup-bundling.js +71 -0
  22. package/src/builders/dev-server/builder.d.ts +32 -0
  23. package/src/builders/dev-server/builder.js +70 -0
  24. package/src/builders/dev-server/index.d.ts +14 -0
  25. package/src/builders/dev-server/index.js +15 -0
  26. package/src/builders/dev-server/internal.d.ts +19 -0
  27. package/src/builders/dev-server/internal.js +29 -0
  28. package/src/builders/dev-server/options.d.ts +47 -0
  29. package/src/builders/dev-server/options.js +65 -0
  30. package/src/builders/dev-server/output.d.ts +16 -0
  31. package/src/builders/dev-server/output.js +9 -0
  32. package/src/builders/dev-server/schema.d.ts +118 -0
  33. package/src/builders/dev-server/schema.js +4 -0
  34. package/src/builders/dev-server/schema.json +131 -0
  35. package/src/builders/dev-server/vite-server.d.ts +31 -0
  36. package/src/builders/dev-server/vite-server.js +504 -0
  37. package/src/index.d.ts +11 -0
  38. package/src/index.js +16 -0
  39. package/src/private.d.ts +35 -0
  40. package/src/private.js +70 -0
  41. package/src/tools/babel/plugins/adjust-static-class-members.d.ts +26 -0
  42. package/src/tools/babel/plugins/adjust-static-class-members.js +351 -0
  43. package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +22 -0
  44. package/src/tools/babel/plugins/adjust-typescript-enums.js +113 -0
  45. package/src/tools/babel/plugins/elide-angular-metadata.d.ts +22 -0
  46. package/src/tools/babel/plugins/elide-angular-metadata.js +110 -0
  47. package/src/tools/babel/plugins/index.d.ts +11 -0
  48. package/src/tools/babel/plugins/index.js +21 -0
  49. package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +15 -0
  50. package/src/tools/babel/plugins/pure-toplevel-functions.js +90 -0
  51. package/src/tools/babel/typings.d.ts +21 -0
  52. package/src/tools/esbuild/angular/angular-host.d.ts +26 -0
  53. package/src/tools/esbuild/angular/angular-host.js +134 -0
  54. package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +42 -0
  55. package/src/tools/esbuild/angular/compilation/angular-compilation.js +94 -0
  56. package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +21 -0
  57. package/src/tools/esbuild/angular/compilation/aot-compilation.js +224 -0
  58. package/src/tools/esbuild/angular/compilation/factory.d.ts +16 -0
  59. package/src/tools/esbuild/angular/compilation/factory.js +56 -0
  60. package/src/tools/esbuild/angular/compilation/index.d.ts +10 -0
  61. package/src/tools/esbuild/angular/compilation/index.js +17 -0
  62. package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.d.ts +10 -0
  63. package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.js +182 -0
  64. package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +21 -0
  65. package/src/tools/esbuild/angular/compilation/jit-compilation.js +106 -0
  66. package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +20 -0
  67. package/src/tools/esbuild/angular/compilation/noop-compilation.js +26 -0
  68. package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +42 -0
  69. package/src/tools/esbuild/angular/compilation/parallel-compilation.js +123 -0
  70. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +33 -0
  71. package/src/tools/esbuild/angular/compilation/parallel-worker.js +90 -0
  72. package/src/tools/esbuild/angular/compilation-state.d.ts +15 -0
  73. package/src/tools/esbuild/angular/compilation-state.js +44 -0
  74. package/src/tools/esbuild/angular/compiler-plugin.d.ts +27 -0
  75. package/src/tools/esbuild/angular/compiler-plugin.js +441 -0
  76. package/src/tools/esbuild/angular/component-stylesheets.d.ts +44 -0
  77. package/src/tools/esbuild/angular/component-stylesheets.js +150 -0
  78. package/src/tools/esbuild/angular/diagnostics.d.ts +15 -0
  79. package/src/tools/esbuild/angular/diagnostics.js +69 -0
  80. package/src/tools/esbuild/angular/file-reference-tracker.d.ts +17 -0
  81. package/src/tools/esbuild/angular/file-reference-tracker.js +57 -0
  82. package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +23 -0
  83. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +117 -0
  84. package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +17 -0
  85. package/src/tools/esbuild/angular/jit-resource-transformer.js +186 -0
  86. package/src/tools/esbuild/angular/source-file-cache.d.ts +18 -0
  87. package/src/tools/esbuild/angular/source-file-cache.js +65 -0
  88. package/src/tools/esbuild/angular/uri.d.ts +54 -0
  89. package/src/tools/esbuild/angular/uri.js +74 -0
  90. package/src/tools/esbuild/angular/web-worker-transformer.d.ts +17 -0
  91. package/src/tools/esbuild/angular/web-worker-transformer.js +94 -0
  92. package/src/tools/esbuild/application-code-bundle.d.ts +20 -0
  93. package/src/tools/esbuild/application-code-bundle.js +368 -0
  94. package/src/tools/esbuild/budget-stats.d.ts +19 -0
  95. package/src/tools/esbuild/budget-stats.js +59 -0
  96. package/src/tools/esbuild/bundler-context.d.ts +75 -0
  97. package/src/tools/esbuild/bundler-context.js +366 -0
  98. package/src/tools/esbuild/bundler-execution-result.d.ts +71 -0
  99. package/src/tools/esbuild/bundler-execution-result.js +131 -0
  100. package/src/tools/esbuild/cache.d.ts +88 -0
  101. package/src/tools/esbuild/cache.js +92 -0
  102. package/src/tools/esbuild/commonjs-checker.d.ts +28 -0
  103. package/src/tools/esbuild/commonjs-checker.js +151 -0
  104. package/src/tools/esbuild/compiler-plugin-options.d.ts +16 -0
  105. package/src/tools/esbuild/compiler-plugin-options.js +49 -0
  106. package/src/tools/esbuild/external-packages-plugin.d.ts +18 -0
  107. package/src/tools/esbuild/external-packages-plugin.js +70 -0
  108. package/src/tools/esbuild/global-scripts.d.ts +16 -0
  109. package/src/tools/esbuild/global-scripts.js +142 -0
  110. package/src/tools/esbuild/global-styles.d.ts +10 -0
  111. package/src/tools/esbuild/global-styles.js +74 -0
  112. package/src/tools/esbuild/i18n-inliner-worker.d.ts +42 -0
  113. package/src/tools/esbuild/i18n-inliner-worker.js +136 -0
  114. package/src/tools/esbuild/i18n-inliner.d.ts +44 -0
  115. package/src/tools/esbuild/i18n-inliner.js +150 -0
  116. package/src/tools/esbuild/i18n-locale-plugin.d.ts +22 -0
  117. package/src/tools/esbuild/i18n-locale-plugin.js +120 -0
  118. package/src/tools/esbuild/index-html-generator.d.ts +15 -0
  119. package/src/tools/esbuild/index-html-generator.js +81 -0
  120. package/src/tools/esbuild/javascript-transformer-worker.d.ts +19 -0
  121. package/src/tools/esbuild/javascript-transformer-worker.js +154 -0
  122. package/src/tools/esbuild/javascript-transformer.d.ts +54 -0
  123. package/src/tools/esbuild/javascript-transformer.js +147 -0
  124. package/src/tools/esbuild/license-extractor.d.ts +25 -0
  125. package/src/tools/esbuild/license-extractor.js +158 -0
  126. package/src/tools/esbuild/load-result-cache.d.ts +21 -0
  127. package/src/tools/esbuild/load-result-cache.js +75 -0
  128. package/src/tools/esbuild/profiling.d.ts +11 -0
  129. package/src/tools/esbuild/profiling.js +78 -0
  130. package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +18 -0
  131. package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +44 -0
  132. package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +17 -0
  133. package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +73 -0
  134. package/src/tools/esbuild/stylesheets/bundle-options.d.ts +35 -0
  135. package/src/tools/esbuild/stylesheets/bundle-options.js +64 -0
  136. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +25 -0
  137. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +57 -0
  138. package/src/tools/esbuild/stylesheets/css-language.d.ts +9 -0
  139. package/src/tools/esbuild/stylesheets/css-language.js +15 -0
  140. package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +18 -0
  141. package/src/tools/esbuild/stylesheets/css-resource-plugin.js +114 -0
  142. package/src/tools/esbuild/stylesheets/less-language.d.ts +9 -0
  143. package/src/tools/esbuild/stylesheets/less-language.js +155 -0
  144. package/src/tools/esbuild/stylesheets/sass-language.d.ts +10 -0
  145. package/src/tools/esbuild/stylesheets/sass-language.js +185 -0
  146. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +58 -0
  147. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +282 -0
  148. package/src/tools/esbuild/utils.d.ts +49 -0
  149. package/src/tools/esbuild/utils.js +392 -0
  150. package/src/tools/esbuild/virtual-module-plugin.d.ts +33 -0
  151. package/src/tools/esbuild/virtual-module-plugin.js +43 -0
  152. package/src/tools/esbuild/watcher.d.ts +25 -0
  153. package/src/tools/esbuild/watcher.js +118 -0
  154. package/src/tools/sass/lexer.d.ts +18 -0
  155. package/src/tools/sass/lexer.js +161 -0
  156. package/src/tools/sass/rebasing-importer.d.ts +101 -0
  157. package/src/tools/sass/rebasing-importer.js +334 -0
  158. package/src/tools/sass/sass-service.d.ts +72 -0
  159. package/src/tools/sass/sass-service.js +213 -0
  160. package/src/tools/sass/worker.d.ts +8 -0
  161. package/src/tools/sass/worker.js +192 -0
  162. package/src/tools/vite/angular-memory-plugin.d.ts +24 -0
  163. package/src/tools/vite/angular-memory-plugin.js +268 -0
  164. package/src/tools/vite/i18n-locale-plugin.d.ts +18 -0
  165. package/src/tools/vite/i18n-locale-plugin.js +55 -0
  166. package/src/utils/bundle-calculator.d.ts +44 -0
  167. package/src/utils/bundle-calculator.js +303 -0
  168. package/src/utils/check-port.d.ts +8 -0
  169. package/src/utils/check-port.js +58 -0
  170. package/src/utils/color.d.ts +10 -0
  171. package/src/utils/color.js +63 -0
  172. package/src/utils/delete-output-dir.d.ts +11 -0
  173. package/src/utils/delete-output-dir.js +46 -0
  174. package/src/utils/environment-options.d.ts +16 -0
  175. package/src/utils/environment-options.js +79 -0
  176. package/src/utils/error.d.ts +10 -0
  177. package/src/utils/error.js +21 -0
  178. package/src/utils/format-bytes.d.ts +8 -0
  179. package/src/utils/format-bytes.js +22 -0
  180. package/src/utils/i18n-options.d.ts +33 -0
  181. package/src/utils/i18n-options.js +161 -0
  182. package/src/utils/index-file/add-event-dispatch-contract.d.ts +8 -0
  183. package/src/utils/index-file/add-event-dispatch-contract.js +28 -0
  184. package/src/utils/index-file/augment-index-html.d.ts +40 -0
  185. package/src/utils/index-file/augment-index-html.js +239 -0
  186. package/src/utils/index-file/html-rewriting-stream.d.ts +11 -0
  187. package/src/utils/index-file/html-rewriting-stream.js +28 -0
  188. package/src/utils/index-file/index-html-generator.d.ts +57 -0
  189. package/src/utils/index-file/index-html-generator.js +135 -0
  190. package/src/utils/index-file/inline-critical-css.d.ts +24 -0
  191. package/src/utils/index-file/inline-critical-css.js +179 -0
  192. package/src/utils/index-file/inline-fonts.d.ts +23 -0
  193. package/src/utils/index-file/inline-fonts.js +267 -0
  194. package/src/utils/index-file/nonce.d.ts +12 -0
  195. package/src/utils/index-file/nonce.js +55 -0
  196. package/src/utils/index-file/style-nonce.d.ts +12 -0
  197. package/src/utils/index-file/style-nonce.js +55 -0
  198. package/src/utils/index.d.ts +11 -0
  199. package/src/utils/index.js +27 -0
  200. package/src/utils/load-esm.d.ts +20 -0
  201. package/src/utils/load-esm.js +31 -0
  202. package/src/utils/load-proxy-config.d.ts +8 -0
  203. package/src/utils/load-proxy-config.js +189 -0
  204. package/src/utils/load-translations.d.ts +16 -0
  205. package/src/utils/load-translations.js +84 -0
  206. package/src/utils/normalize-asset-patterns.d.ts +14 -0
  207. package/src/utils/normalize-asset-patterns.js +96 -0
  208. package/src/utils/normalize-cache.d.ts +16 -0
  209. package/src/utils/normalize-cache.js +44 -0
  210. package/src/utils/normalize-optimization.d.ts +13 -0
  211. package/src/utils/normalize-optimization.js +42 -0
  212. package/src/utils/normalize-source-maps.d.ts +9 -0
  213. package/src/utils/normalize-source-maps.js +23 -0
  214. package/src/utils/postcss-configuration.d.ts +17 -0
  215. package/src/utils/postcss-configuration.js +86 -0
  216. package/src/utils/purge-cache.d.ts +10 -0
  217. package/src/utils/purge-cache.js +40 -0
  218. package/src/utils/resolve-assets.d.ts +18 -0
  219. package/src/utils/resolve-assets.js +35 -0
  220. package/src/utils/routes-extractor/extractor.d.ts +15 -0
  221. package/src/utils/routes-extractor/extractor.js +97 -0
  222. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +18 -0
  223. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +129 -0
  224. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +8 -0
  225. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +13 -0
  226. package/src/utils/server-rendering/fetch-patch.d.ts +8 -0
  227. package/src/utils/server-rendering/fetch-patch.js +66 -0
  228. package/src/utils/server-rendering/load-esm-from-memory.d.ts +10 -0
  229. package/src/utils/server-rendering/load-esm-from-memory.js +26 -0
  230. package/src/utils/server-rendering/main-bundle-exports.d.ts +27 -0
  231. package/src/utils/server-rendering/main-bundle-exports.js +9 -0
  232. package/src/utils/server-rendering/prerender.d.ts +23 -0
  233. package/src/utils/server-rendering/prerender.js +192 -0
  234. package/src/utils/server-rendering/render-page.d.ts +26 -0
  235. package/src/utils/server-rendering/render-page.js +110 -0
  236. package/src/utils/server-rendering/render-worker.d.ts +22 -0
  237. package/src/utils/server-rendering/render-worker.js +30 -0
  238. package/src/utils/server-rendering/routes-extractor-worker.d.ts +21 -0
  239. package/src/utils/server-rendering/routes-extractor-worker.js +53 -0
  240. package/src/utils/service-worker.d.ts +25 -0
  241. package/src/utils/service-worker.js +211 -0
  242. package/src/utils/spinner.d.ts +20 -0
  243. package/src/utils/spinner.js +55 -0
  244. package/src/utils/stats-table.d.ts +20 -0
  245. package/src/utils/stats-table.js +205 -0
  246. package/src/utils/supported-browsers.d.ts +10 -0
  247. package/src/utils/supported-browsers.js +42 -0
  248. package/src/utils/tty.d.ts +8 -0
  249. package/src/utils/tty.js +23 -0
  250. package/src/utils/url.d.ts +8 -0
  251. package/src/utils/url.js +18 -0
  252. package/src/utils/version.d.ts +8 -0
  253. package/src/utils/version.js +59 -0
@@ -0,0 +1,40 @@
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.purgeStaleBuildCache = void 0;
11
+ const promises_1 = require("node:fs/promises");
12
+ const node_path_1 = require("node:path");
13
+ const normalize_cache_1 = require("./normalize-cache");
14
+ /** Delete stale cache directories used by previous versions of build-angular. */
15
+ async function purgeStaleBuildCache(context) {
16
+ const projectName = context.target?.project;
17
+ if (!projectName) {
18
+ return;
19
+ }
20
+ const metadata = await context.getProjectMetadata(projectName);
21
+ const { basePath, path, enabled } = (0, normalize_cache_1.normalizeCacheOptions)(metadata, context.workspaceRoot);
22
+ if (!enabled) {
23
+ return;
24
+ }
25
+ let baseEntries;
26
+ try {
27
+ baseEntries = await (0, promises_1.readdir)(basePath, { withFileTypes: true });
28
+ }
29
+ catch {
30
+ // No purging possible if base path does not exist or cannot otherwise be accessed
31
+ return;
32
+ }
33
+ const entriesToDelete = baseEntries
34
+ .filter((d) => d.isDirectory())
35
+ .map((d) => (0, node_path_1.join)(basePath, d.name))
36
+ .filter((cachePath) => cachePath !== path)
37
+ .map((stalePath) => (0, promises_1.rm)(stalePath, { force: true, recursive: true, maxRetries: 3 }));
38
+ await Promise.allSettled(entriesToDelete);
39
+ }
40
+ exports.purgeStaleBuildCache = purgeStaleBuildCache;
@@ -0,0 +1,18 @@
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 resolveAssets(entries: {
9
+ glob: string;
10
+ ignore?: string[];
11
+ input: string;
12
+ output: string;
13
+ flatten?: boolean;
14
+ followSymlinks?: boolean;
15
+ }[], root: string): Promise<{
16
+ source: string;
17
+ destination: string;
18
+ }[]>;
@@ -0,0 +1,35 @@
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.resolveAssets = void 0;
14
+ const fast_glob_1 = __importDefault(require("fast-glob"));
15
+ const node_path_1 = __importDefault(require("node:path"));
16
+ async function resolveAssets(entries, root) {
17
+ const defaultIgnore = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db'];
18
+ const outputFiles = [];
19
+ for (const entry of entries) {
20
+ const cwd = node_path_1.default.resolve(root, entry.input);
21
+ const files = await (0, fast_glob_1.default)(entry.glob, {
22
+ cwd,
23
+ dot: true,
24
+ ignore: entry.ignore ? defaultIgnore.concat(entry.ignore) : defaultIgnore,
25
+ followSymbolicLinks: entry.followSymlinks,
26
+ });
27
+ for (const file of files) {
28
+ const src = node_path_1.default.join(cwd, file);
29
+ const filePath = entry.flatten ? node_path_1.default.basename(file) : file;
30
+ outputFiles.push({ source: src, destination: node_path_1.default.join(entry.output, filePath) });
31
+ }
32
+ }
33
+ return outputFiles;
34
+ }
35
+ exports.resolveAssets = resolveAssets;
@@ -0,0 +1,15 @@
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 { ApplicationRef, Type } from '@angular/core';
9
+ interface RouterResult {
10
+ route: string;
11
+ success: boolean;
12
+ redirect: boolean;
13
+ }
14
+ export declare function extractRoutes(bootstrapAppFnOrModule: (() => Promise<ApplicationRef>) | Type<unknown>, document: string): AsyncIterableIterator<RouterResult>;
15
+ export {};
@@ -0,0 +1,97 @@
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 { ApplicationRef, Compiler, createPlatformFactory, platformCore, ɵwhenStable as whenStable, ɵConsole, } from '@angular/core';
9
+ import { INITIAL_CONFIG, ɵINTERNAL_SERVER_PLATFORM_PROVIDERS as INTERNAL_SERVER_PLATFORM_PROVIDERS, } from '@angular/platform-server';
10
+ import { Router, ɵloadChildren as loadChildrenHelper } from '@angular/router';
11
+ async function* getRoutesFromRouterConfig(routes, compiler, parentInjector, parentRoute = '') {
12
+ for (const route of routes) {
13
+ const { path, redirectTo, loadChildren, children } = route;
14
+ if (path === undefined) {
15
+ continue;
16
+ }
17
+ const currentRoutePath = buildRoutePath(parentRoute, path);
18
+ if (redirectTo !== undefined) {
19
+ // TODO: handle `redirectTo`.
20
+ yield { route: currentRoutePath, success: false, redirect: true };
21
+ continue;
22
+ }
23
+ if (/[:*]/.test(path)) {
24
+ // TODO: handle parameterized routes population.
25
+ yield { route: currentRoutePath, success: false, redirect: false };
26
+ continue;
27
+ }
28
+ yield { route: currentRoutePath, success: true, redirect: false };
29
+ if (children?.length) {
30
+ yield* getRoutesFromRouterConfig(children, compiler, parentInjector, currentRoutePath);
31
+ }
32
+ if (loadChildren) {
33
+ const loadedChildRoutes = await loadChildrenHelper(route, compiler, parentInjector).toPromise();
34
+ if (loadedChildRoutes) {
35
+ const { routes: childRoutes, injector = parentInjector } = loadedChildRoutes;
36
+ yield* getRoutesFromRouterConfig(childRoutes, compiler, injector, currentRoutePath);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ export async function* extractRoutes(bootstrapAppFnOrModule, document) {
42
+ const platformRef = createPlatformFactory(platformCore, 'server', [
43
+ {
44
+ provide: INITIAL_CONFIG,
45
+ useValue: { document, url: '' },
46
+ },
47
+ {
48
+ provide: ɵConsole,
49
+ /** An Angular Console Provider that does not print a set of predefined logs. */
50
+ useFactory: () => {
51
+ class Console extends ɵConsole {
52
+ ignoredLogs = new Set(['Angular is running in development mode.']);
53
+ log(message) {
54
+ if (!this.ignoredLogs.has(message)) {
55
+ super.log(message);
56
+ }
57
+ }
58
+ }
59
+ return new Console();
60
+ },
61
+ },
62
+ ...INTERNAL_SERVER_PLATFORM_PROVIDERS,
63
+ ])();
64
+ try {
65
+ let applicationRef;
66
+ if (isBootstrapFn(bootstrapAppFnOrModule)) {
67
+ applicationRef = await bootstrapAppFnOrModule();
68
+ }
69
+ else {
70
+ const moduleRef = await platformRef.bootstrapModule(bootstrapAppFnOrModule);
71
+ applicationRef = moduleRef.injector.get(ApplicationRef);
72
+ }
73
+ // Wait until the application is stable.
74
+ await whenStable(applicationRef);
75
+ const injector = applicationRef.injector;
76
+ const router = injector.get(Router);
77
+ if (router.config.length === 0) {
78
+ // In case there are no routes available
79
+ yield { route: '', success: true, redirect: false };
80
+ }
81
+ else {
82
+ const compiler = injector.get(Compiler);
83
+ // Extract all the routes from the config.
84
+ yield* getRoutesFromRouterConfig(router.config, compiler, injector);
85
+ }
86
+ }
87
+ finally {
88
+ platformRef.destroy();
89
+ }
90
+ }
91
+ function isBootstrapFn(value) {
92
+ // We can differentiate between a module and a bootstrap function by reading compiler-generated `ɵmod` static property:
93
+ return typeof value === 'function' && !('ɵmod' in value);
94
+ }
95
+ function buildRoutePath(...routeParts) {
96
+ return routeParts.filter(Boolean).join('/');
97
+ }
@@ -0,0 +1,18 @@
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 interface ESMInMemoryFileLoaderWorkerData {
9
+ outputFiles: Record<string, string>;
10
+ workspaceRoot: string;
11
+ }
12
+ export declare function initialize(data: ESMInMemoryFileLoaderWorkerData): void;
13
+ export declare function resolve(specifier: string, context: {
14
+ parentURL: undefined | string;
15
+ }, nextResolve: Function): any;
16
+ export declare function load(url: string, context: {
17
+ format?: string | null;
18
+ }, nextLoad: Function): Promise<any>;
@@ -0,0 +1,129 @@
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);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ export {};
@@ -0,0 +1,13 @@
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 });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ export declare function patchFetchToLoadInMemoryAssets(): void;
@@ -0,0 +1,66 @@
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;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ 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>;
@@ -0,0 +1,26 @@
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;
@@ -0,0 +1,27 @@
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
+ }
@@ -0,0 +1,9 @@
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 });
@@ -0,0 +1,23 @@
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 {};