@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,268 +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.createAngularMemoryPlugin = void 0;
14
- const remapping_1 = __importDefault(require("@ampproject/remapping"));
15
- const mrmime_1 = require("mrmime");
16
- const node_assert_1 = __importDefault(require("node:assert"));
17
- const promises_1 = require("node:fs/promises");
18
- const node_path_1 = require("node:path");
19
- const render_page_1 = require("../../utils/server-rendering/render-page");
20
- // eslint-disable-next-line max-lines-per-function
21
- function createAngularMemoryPlugin(options) {
22
- const { workspaceRoot, virtualProjectRoot, outputFiles, assets, external, ssr, extensionMiddleware, extraHeaders, indexHtmlTransformer, normalizePath, } = options;
23
- return {
24
- name: 'vite:angular-memory',
25
- // Ensures plugin hooks run before built-in Vite hooks
26
- enforce: 'pre',
27
- async resolveId(source, importer) {
28
- // Prevent vite from resolving an explicit external dependency (`externalDependencies` option)
29
- if (external?.includes(source)) {
30
- // This is still not ideal since Vite will still transform the import specifier to
31
- // `/@id/${source}` but is currently closer to a raw external than a resolved file path.
32
- return source;
33
- }
34
- if (importer && source[0] === '.' && importer.startsWith(virtualProjectRoot)) {
35
- // Remove query if present
36
- const [importerFile] = importer.split('?', 1);
37
- source =
38
- '/' + normalizePath((0, node_path_1.join)((0, node_path_1.dirname)((0, node_path_1.relative)(virtualProjectRoot, importerFile)), source));
39
- }
40
- const [file] = source.split('?', 1);
41
- if (outputFiles.has(file)) {
42
- return (0, node_path_1.join)(virtualProjectRoot, source);
43
- }
44
- },
45
- async load(id) {
46
- const [file] = id.split('?', 1);
47
- const relativeFile = '/' + normalizePath((0, node_path_1.relative)(virtualProjectRoot, file));
48
- const codeContents = outputFiles.get(relativeFile)?.contents;
49
- if (codeContents === undefined) {
50
- if (relativeFile.endsWith('/node_modules/vite/dist/client/client.mjs')) {
51
- return {
52
- code: await loadViteClientCode(file),
53
- map: await (0, promises_1.readFile)(file + '.map', 'utf-8'),
54
- };
55
- }
56
- return;
57
- }
58
- const code = Buffer.from(codeContents).toString('utf-8');
59
- const mapContents = outputFiles.get(relativeFile + '.map')?.contents;
60
- return {
61
- // Remove source map URL comments from the code if a sourcemap is present.
62
- // Vite will inline and add an additional sourcemap URL for the sourcemap.
63
- code: mapContents ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '') : code,
64
- map: mapContents && Buffer.from(mapContents).toString('utf-8'),
65
- };
66
- },
67
- // eslint-disable-next-line max-lines-per-function
68
- configureServer(server) {
69
- const originalssrTransform = server.ssrTransform;
70
- server.ssrTransform = async (code, map, url, originalCode) => {
71
- const result = await originalssrTransform(code, null, url, originalCode);
72
- if (!result || !result.map || !map) {
73
- return result;
74
- }
75
- const remappedMap = (0, remapping_1.default)([result.map, map], () => null);
76
- // Set the sourcemap root to the workspace root. This is needed since we set a virtual path as root.
77
- remappedMap.sourceRoot = normalizePath(workspaceRoot) + '/';
78
- return {
79
- ...result,
80
- map: remappedMap,
81
- };
82
- };
83
- // Assets and resources get handled first
84
- server.middlewares.use(function angularAssetsMiddleware(req, res, next) {
85
- if (req.url === undefined || res.writableEnded) {
86
- return;
87
- }
88
- // Parse the incoming request.
89
- // The base of the URL is unused but required to parse the URL.
90
- const pathname = pathnameWithoutBasePath(req.url, server.config.base);
91
- const extension = (0, node_path_1.extname)(pathname);
92
- // Rewrite all build assets to a vite raw fs URL
93
- const assetSourcePath = assets.get(pathname);
94
- if (assetSourcePath !== undefined) {
95
- // Workaround to disable Vite transformer middleware.
96
- // See: https://github.com/vitejs/vite/blob/746a1daab0395f98f0afbdee8f364cb6cf2f3b3f/packages/vite/src/node/server/middlewares/transform.ts#L201 and
97
- // https://github.com/vitejs/vite/blob/746a1daab0395f98f0afbdee8f364cb6cf2f3b3f/packages/vite/src/node/server/transformRequest.ts#L204-L206
98
- req.headers.accept = 'text/html';
99
- // The encoding needs to match what happens in the vite static middleware.
100
- // ref: https://github.com/vitejs/vite/blob/d4f13bd81468961c8c926438e815ab6b1c82735e/packages/vite/src/node/server/middlewares/static.ts#L163
101
- req.url = `${server.config.base}@fs/${encodeURI(assetSourcePath)}`;
102
- next();
103
- return;
104
- }
105
- // HTML fallbacking
106
- // This matches what happens in the vite html fallback middleware.
107
- // ref: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/htmlFallback.ts#L9
108
- const htmlAssetSourcePath = pathname[pathname.length - 1] === '/'
109
- ? // Trailing slash check for `index.html`.
110
- assets.get(pathname + 'index.html')
111
- : // Non-trailing slash check for fallback `.html`
112
- assets.get(pathname + '.html');
113
- if (htmlAssetSourcePath) {
114
- req.url = `${server.config.base}@fs/${encodeURI(htmlAssetSourcePath)}`;
115
- next();
116
- return;
117
- }
118
- // Resource files are handled directly.
119
- // Global stylesheets (CSS files) are currently considered resources to workaround
120
- // dev server sourcemap issues with stylesheets.
121
- if (extension !== '.js' && extension !== '.html') {
122
- const outputFile = outputFiles.get(pathname);
123
- if (outputFile?.servable) {
124
- const mimeType = (0, mrmime_1.lookup)(extension);
125
- if (mimeType) {
126
- res.setHeader('Content-Type', mimeType);
127
- }
128
- res.setHeader('Cache-Control', 'no-cache');
129
- if (extraHeaders) {
130
- Object.entries(extraHeaders).forEach(([name, value]) => res.setHeader(name, value));
131
- }
132
- res.end(outputFile.contents);
133
- return;
134
- }
135
- }
136
- next();
137
- });
138
- if (extensionMiddleware?.length) {
139
- extensionMiddleware.forEach((middleware) => server.middlewares.use(middleware));
140
- }
141
- // Returning a function, installs middleware after the main transform middleware but
142
- // before the built-in HTML middleware
143
- return () => {
144
- server.middlewares.use(angularHtmlFallbackMiddleware);
145
- function angularSSRMiddleware(req, res, next) {
146
- const url = req.originalUrl;
147
- if (!req.url ||
148
- // Skip if path is not defined.
149
- !url ||
150
- // Skip if path is like a file.
151
- // NOTE: We use a mime type lookup to mitigate against matching requests like: /browse/pl.0ef59752c0cd457dbf1391f08cbd936f
152
- lookupMimeTypeFromRequest(url)) {
153
- next();
154
- return;
155
- }
156
- const rawHtml = outputFiles.get('/index.server.html')?.contents;
157
- if (!rawHtml) {
158
- next();
159
- return;
160
- }
161
- transformIndexHtmlAndAddHeaders(req.url, rawHtml, res, next, async (html) => {
162
- const resolvedUrls = server.resolvedUrls;
163
- const baseUrl = resolvedUrls?.local[0] ?? resolvedUrls?.network[0];
164
- const { content } = await (0, render_page_1.renderPage)({
165
- document: html,
166
- route: new URL(req.originalUrl ?? '/', baseUrl).toString(),
167
- serverContext: 'ssr',
168
- loadBundle: (uri) =>
169
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
170
- server.ssrLoadModule(uri.slice(1)),
171
- // Files here are only needed for critical CSS inlining.
172
- outputFiles: {},
173
- // TODO: add support for critical css inlining.
174
- inlineCriticalCss: false,
175
- });
176
- return indexHtmlTransformer && content ? await indexHtmlTransformer(content) : content;
177
- });
178
- }
179
- if (ssr) {
180
- server.middlewares.use(angularSSRMiddleware);
181
- }
182
- server.middlewares.use(function angularIndexMiddleware(req, res, next) {
183
- if (!req.url) {
184
- next();
185
- return;
186
- }
187
- // Parse the incoming request.
188
- // The base of the URL is unused but required to parse the URL.
189
- const pathname = pathnameWithoutBasePath(req.url, server.config.base);
190
- if (pathname === '/' || pathname === `/index.html`) {
191
- const rawHtml = outputFiles.get('/index.html')?.contents;
192
- if (rawHtml) {
193
- transformIndexHtmlAndAddHeaders(req.url, rawHtml, res, next, indexHtmlTransformer);
194
- return;
195
- }
196
- }
197
- next();
198
- });
199
- };
200
- function transformIndexHtmlAndAddHeaders(url, rawHtml, res, next, additionalTransformer) {
201
- server
202
- .transformIndexHtml(url, Buffer.from(rawHtml).toString('utf-8'))
203
- .then(async (processedHtml) => {
204
- if (additionalTransformer) {
205
- const content = await additionalTransformer(processedHtml);
206
- if (!content) {
207
- next();
208
- return;
209
- }
210
- processedHtml = content;
211
- }
212
- res.setHeader('Content-Type', 'text/html');
213
- res.setHeader('Cache-Control', 'no-cache');
214
- if (extraHeaders) {
215
- Object.entries(extraHeaders).forEach(([name, value]) => res.setHeader(name, value));
216
- }
217
- res.end(processedHtml);
218
- })
219
- .catch((error) => next(error));
220
- }
221
- },
222
- };
223
- }
224
- exports.createAngularMemoryPlugin = createAngularMemoryPlugin;
225
- /**
226
- * Reads the resolved Vite client code from disk and updates the content to remove
227
- * an unactionable suggestion to update the Vite configuration file to disable the
228
- * error overlay. The Vite configuration file is not present when used in the Angular
229
- * CLI.
230
- * @param file The absolute path to the Vite client code.
231
- * @returns
232
- */
233
- async function loadViteClientCode(file) {
234
- const originalContents = await (0, promises_1.readFile)(file, 'utf-8');
235
- const updatedContents = originalContents.replace(`h('br'), 'You can also disable this overlay by setting ', ` +
236
- `h('code', { part: 'config-option-name' }, 'server.hmr.overlay'), '` +
237
- ` to ', h('code', { part: 'config-option-value' }, 'false'), ' in ', h('code', { part: 'config-file-name' }, hmrConfigName), '.'`, '');
238
- (0, node_assert_1.default)(originalContents !== updatedContents, 'Failed to update Vite client error overlay text.');
239
- return updatedContents;
240
- }
241
- function pathnameWithoutBasePath(url, basePath) {
242
- const parsedUrl = new URL(url, 'http://localhost');
243
- const pathname = decodeURIComponent(parsedUrl.pathname);
244
- // slice(basePath.length - 1) to retain the trailing slash
245
- return basePath !== '/' && pathname.startsWith(basePath)
246
- ? pathname.slice(basePath.length - 1)
247
- : pathname;
248
- }
249
- function angularHtmlFallbackMiddleware(req, res, next) {
250
- // Similar to how it is handled in vite
251
- // https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/htmlFallback.ts#L15C19-L15C45
252
- if ((req.method === 'GET' || req.method === 'HEAD') &&
253
- (!req.url || !lookupMimeTypeFromRequest(req.url)) &&
254
- (!req.headers.accept ||
255
- req.headers.accept.includes('text/html') ||
256
- req.headers.accept.includes('text/*') ||
257
- req.headers.accept.includes('*/*'))) {
258
- req.url = '/index.html';
259
- }
260
- next();
261
- }
262
- function lookupMimeTypeFromRequest(url) {
263
- const extension = (0, node_path_1.extname)(url.split('?')[0]);
264
- if (extension === '.ico') {
265
- return 'image/x-icon';
266
- }
267
- return extension && (0, mrmime_1.lookup)(extension);
268
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import type { Plugin } from 'vite';
9
- /**
10
- * The base module location used to search for locale specific data.
11
- */
12
- export declare const LOCALE_DATA_BASE_MODULE = "@angular/common/locales/global";
13
- /**
14
- * Creates a Vite plugin that resolves Angular locale data files from `@angular/common`.
15
- *
16
- * @returns A Vite plugin.
17
- */
18
- export declare function createAngularLocaleDataPlugin(): Plugin;
@@ -1,55 +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.createAngularLocaleDataPlugin = exports.LOCALE_DATA_BASE_MODULE = void 0;
11
- /**
12
- * The base module location used to search for locale specific data.
13
- */
14
- exports.LOCALE_DATA_BASE_MODULE = '@angular/common/locales/global';
15
- /**
16
- * Creates a Vite plugin that resolves Angular locale data files from `@angular/common`.
17
- *
18
- * @returns A Vite plugin.
19
- */
20
- function createAngularLocaleDataPlugin() {
21
- return {
22
- name: 'angular-locale-data',
23
- enforce: 'pre',
24
- async resolveId(source) {
25
- if (!source.startsWith('angular:locale/data:')) {
26
- return;
27
- }
28
- // Extract the locale from the path
29
- const originalLocale = source.split(':', 3)[2];
30
- // Remove any private subtags since these will never match
31
- let partialLocale = originalLocale.replace(/-x(-[a-zA-Z0-9]{1,8})+$/, '');
32
- let exact = true;
33
- while (partialLocale) {
34
- const potentialPath = `${exports.LOCALE_DATA_BASE_MODULE}/${partialLocale}`;
35
- const result = await this.resolve(potentialPath);
36
- if (result) {
37
- if (!exact) {
38
- this.warn(`Locale data for '${originalLocale}' cannot be found. Using locale data for '${partialLocale}'.`);
39
- }
40
- return result;
41
- }
42
- // Remove the last subtag and try again with a less specific locale
43
- const parts = partialLocale.split('-');
44
- partialLocale = parts.slice(0, -1).join('-');
45
- exact = false;
46
- // The locales "en" and "en-US" are considered exact to retain existing behavior
47
- if (originalLocale === 'en-US' && partialLocale === 'en') {
48
- exact = true;
49
- }
50
- }
51
- return null;
52
- },
53
- };
54
- }
55
- exports.createAngularLocaleDataPlugin = createAngularLocaleDataPlugin;
package/src/typings.d.ts DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
-
9
- declare module '@babel/helper-annotate-as-pure' {
10
- export default function annotateAsPure(
11
- pathOrNode: import('@babel/types').Node | { node: import('@babel/types').Node },
12
- ): void;
13
- }
14
-
15
- declare module '@babel/helper-split-export-declaration' {
16
- export default function splitExportDeclaration(
17
- exportDeclaration: import('@babel/core').NodePath<
18
- import('@babel/types').ExportDefaultDeclaration
19
- >,
20
- ): void;
21
- }
@@ -1,44 +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 { Budget as BudgetEntry, Type as BudgetType } from '../builders/application/schema';
9
- export { BudgetEntry, BudgetType };
10
- export interface Threshold {
11
- limit: number;
12
- type: ThresholdType;
13
- severity: ThresholdSeverity;
14
- }
15
- declare enum ThresholdType {
16
- Max = "maximum",
17
- Min = "minimum"
18
- }
19
- export declare enum ThresholdSeverity {
20
- Warning = "warning",
21
- Error = "error"
22
- }
23
- export interface BudgetCalculatorResult {
24
- severity: ThresholdSeverity;
25
- message: string;
26
- label?: string;
27
- }
28
- export interface BudgetChunk {
29
- files?: string[];
30
- names?: string[];
31
- initial?: boolean;
32
- }
33
- export interface BudgetAsset {
34
- name: string;
35
- size: number;
36
- componentStyle?: boolean;
37
- }
38
- export interface BudgetStats {
39
- chunks?: BudgetChunk[];
40
- assets?: BudgetAsset[];
41
- }
42
- export declare function calculateThresholds(budget: BudgetEntry): IterableIterator<Threshold>;
43
- export declare function checkBudgets(budgets: BudgetEntry[], stats: BudgetStats, checkComponentStyles?: boolean): IterableIterator<BudgetCalculatorResult>;
44
- export declare function checkThresholds(thresholds: Iterable<Threshold>, size: number, label?: string): IterableIterator<BudgetCalculatorResult>;