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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/builders.json +1 -5
  2. package/package.json +21 -20
  3. package/src/builders/app-shell/index.js +3 -5
  4. package/src/builders/browser/index.d.ts +1 -1
  5. package/src/builders/browser/index.js +9 -13
  6. package/src/builders/browser-esbuild/index.d.ts +2 -2
  7. package/src/builders/browser-esbuild/index.js +6 -9
  8. package/src/builders/dev-server/builder.d.ts +2 -2
  9. package/src/builders/dev-server/builder.js +11 -6
  10. package/src/builders/dev-server/index.d.ts +1 -1
  11. package/src/builders/dev-server/webpack-server.d.ts +1 -1
  12. package/src/builders/dev-server/webpack-server.js +5 -6
  13. package/src/builders/extract-i18n/application-extraction.js +2 -2
  14. package/src/builders/extract-i18n/builder.js +3 -4
  15. package/src/builders/extract-i18n/options.d.ts +1 -1
  16. package/src/builders/extract-i18n/options.js +2 -2
  17. package/src/builders/jest/index.js +2 -2
  18. package/src/builders/karma/index.js +3 -4
  19. package/src/builders/ng-packagr/index.js +8 -7
  20. package/src/builders/ng-packagr/schema.d.ts +4 -0
  21. package/src/builders/ng-packagr/schema.json +4 -0
  22. package/src/builders/prerender/index.js +2 -2
  23. package/src/builders/prerender/render-worker.js +1 -1
  24. package/src/builders/server/index.js +3 -4
  25. package/src/builders/server/platform-server-exports-loader.js +2 -1
  26. package/src/builders/ssr-dev-server/index.js +34 -34
  27. package/src/builders/web-test-runner/index.js +2 -2
  28. package/src/index.d.ts +1 -1
  29. package/src/index.js +2 -2
  30. package/src/tools/babel/presets/application.js +1 -1
  31. package/src/tools/webpack/configs/styles.js +2 -2
  32. package/src/tools/webpack/plugins/any-component-style-budget-checker.d.ts +2 -2
  33. package/src/tools/webpack/plugins/any-component-style-budget-checker.js +14 -17
  34. package/src/tools/webpack/plugins/css-optimizer-plugin.js +2 -2
  35. package/src/tools/webpack/plugins/index-html-webpack-plugin.d.ts +1 -1
  36. package/src/tools/webpack/plugins/index-html-webpack-plugin.js +3 -3
  37. package/src/tools/webpack/plugins/javascript-optimizer-plugin.js +2 -2
  38. package/src/tools/webpack/plugins/service-worker-plugin.js +2 -2
  39. package/src/tools/webpack/utils/stats.d.ts +1 -14
  40. package/src/tools/webpack/utils/stats.js +3 -207
  41. package/src/utils/action-executor.d.ts +1 -1
  42. package/src/utils/i18n-inlining.d.ts +1 -1
  43. package/src/utils/i18n-webpack.d.ts +16 -0
  44. package/src/utils/i18n-webpack.js +107 -0
  45. package/src/utils/index.d.ts +1 -2
  46. package/src/utils/index.js +4 -2
  47. package/src/utils/normalize-builder-schema.js +2 -2
  48. package/src/utils/normalize-cache.js +1 -1
  49. package/src/utils/normalize-optimization.d.ts +1 -1
  50. package/src/utils/normalize-optimization.js +0 -2
  51. package/src/utils/output-paths.d.ts +1 -1
  52. package/src/utils/webpack-browser-config.d.ts +1 -1
  53. package/src/utils/webpack-browser-config.js +2 -2
  54. package/src/builders/application/build-action.d.ts +0 -33
  55. package/src/builders/application/build-action.js +0 -183
  56. package/src/builders/application/execute-build.d.ts +0 -11
  57. package/src/builders/application/execute-build.js +0 -127
  58. package/src/builders/application/execute-post-bundle.d.ts +0 -25
  59. package/src/builders/application/execute-post-bundle.js +0 -96
  60. package/src/builders/application/i18n.d.ts +0 -29
  61. package/src/builders/application/i18n.js +0 -128
  62. package/src/builders/application/index.d.ts +0 -57
  63. package/src/builders/application/index.js +0 -121
  64. package/src/builders/application/options.d.ts +0 -149
  65. package/src/builders/application/options.js +0 -352
  66. package/src/builders/application/schema.d.ts +0 -512
  67. package/src/builders/application/schema.js +0 -58
  68. package/src/builders/application/schema.json +0 -635
  69. package/src/builders/application/setup-bundling.d.ts +0 -19
  70. package/src/builders/application/setup-bundling.js +0 -71
  71. package/src/builders/dev-server/vite-server.d.ts +0 -30
  72. package/src/builders/dev-server/vite-server.js +0 -502
  73. package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -27
  74. package/src/tools/babel/plugins/adjust-static-class-members.js +0 -351
  75. package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -23
  76. package/src/tools/babel/plugins/adjust-typescript-enums.js +0 -113
  77. package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -23
  78. package/src/tools/babel/plugins/elide-angular-metadata.js +0 -110
  79. package/src/tools/babel/plugins/index.d.ts +0 -11
  80. package/src/tools/babel/plugins/index.js +0 -21
  81. package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -16
  82. package/src/tools/babel/plugins/pure-toplevel-functions.js +0 -90
  83. package/src/tools/esbuild/angular/angular-host.d.ts +0 -26
  84. package/src/tools/esbuild/angular/angular-host.js +0 -72
  85. package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +0 -42
  86. package/src/tools/esbuild/angular/compilation/angular-compilation.js +0 -94
  87. package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +0 -21
  88. package/src/tools/esbuild/angular/compilation/aot-compilation.js +0 -228
  89. package/src/tools/esbuild/angular/compilation/factory.d.ts +0 -16
  90. package/src/tools/esbuild/angular/compilation/factory.js +0 -56
  91. package/src/tools/esbuild/angular/compilation/index.d.ts +0 -10
  92. package/src/tools/esbuild/angular/compilation/index.js +0 -17
  93. package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +0 -21
  94. package/src/tools/esbuild/angular/compilation/jit-compilation.js +0 -106
  95. package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +0 -20
  96. package/src/tools/esbuild/angular/compilation/noop-compilation.js +0 -26
  97. package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +0 -42
  98. package/src/tools/esbuild/angular/compilation/parallel-compilation.js +0 -123
  99. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -33
  100. package/src/tools/esbuild/angular/compilation/parallel-worker.js +0 -90
  101. package/src/tools/esbuild/angular/compilation-state.d.ts +0 -15
  102. package/src/tools/esbuild/angular/compilation-state.js +0 -44
  103. package/src/tools/esbuild/angular/compiler-plugin.d.ts +0 -27
  104. package/src/tools/esbuild/angular/compiler-plugin.js +0 -433
  105. package/src/tools/esbuild/angular/component-stylesheets.d.ts +0 -44
  106. package/src/tools/esbuild/angular/component-stylesheets.js +0 -150
  107. package/src/tools/esbuild/angular/diagnostics.d.ts +0 -15
  108. package/src/tools/esbuild/angular/diagnostics.js +0 -69
  109. package/src/tools/esbuild/angular/file-reference-tracker.d.ts +0 -17
  110. package/src/tools/esbuild/angular/file-reference-tracker.js +0 -57
  111. package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +0 -23
  112. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +0 -117
  113. package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +0 -17
  114. package/src/tools/esbuild/angular/jit-resource-transformer.js +0 -186
  115. package/src/tools/esbuild/angular/source-file-cache.d.ts +0 -18
  116. package/src/tools/esbuild/angular/source-file-cache.js +0 -65
  117. package/src/tools/esbuild/angular/uri.d.ts +0 -54
  118. package/src/tools/esbuild/angular/uri.js +0 -74
  119. package/src/tools/esbuild/angular/web-worker-transformer.d.ts +0 -17
  120. package/src/tools/esbuild/angular/web-worker-transformer.js +0 -94
  121. package/src/tools/esbuild/application-code-bundle.d.ts +0 -20
  122. package/src/tools/esbuild/application-code-bundle.js +0 -368
  123. package/src/tools/esbuild/budget-stats.d.ts +0 -19
  124. package/src/tools/esbuild/budget-stats.js +0 -59
  125. package/src/tools/esbuild/bundler-context.d.ts +0 -75
  126. package/src/tools/esbuild/bundler-context.js +0 -366
  127. package/src/tools/esbuild/bundler-execution-result.d.ts +0 -71
  128. package/src/tools/esbuild/bundler-execution-result.js +0 -131
  129. package/src/tools/esbuild/cache.d.ts +0 -88
  130. package/src/tools/esbuild/cache.js +0 -92
  131. package/src/tools/esbuild/commonjs-checker.d.ts +0 -28
  132. package/src/tools/esbuild/commonjs-checker.js +0 -151
  133. package/src/tools/esbuild/compiler-plugin-options.d.ts +0 -16
  134. package/src/tools/esbuild/compiler-plugin-options.js +0 -49
  135. package/src/tools/esbuild/external-packages-plugin.d.ts +0 -18
  136. package/src/tools/esbuild/external-packages-plugin.js +0 -70
  137. package/src/tools/esbuild/global-scripts.d.ts +0 -16
  138. package/src/tools/esbuild/global-scripts.js +0 -142
  139. package/src/tools/esbuild/global-styles.d.ts +0 -10
  140. package/src/tools/esbuild/global-styles.js +0 -74
  141. package/src/tools/esbuild/i18n-inliner-worker.d.ts +0 -42
  142. package/src/tools/esbuild/i18n-inliner-worker.js +0 -136
  143. package/src/tools/esbuild/i18n-inliner.d.ts +0 -44
  144. package/src/tools/esbuild/i18n-inliner.js +0 -150
  145. package/src/tools/esbuild/i18n-locale-plugin.d.ts +0 -22
  146. package/src/tools/esbuild/i18n-locale-plugin.js +0 -120
  147. package/src/tools/esbuild/index-html-generator.d.ts +0 -15
  148. package/src/tools/esbuild/index-html-generator.js +0 -129
  149. package/src/tools/esbuild/javascript-transformer-worker.d.ts +0 -19
  150. package/src/tools/esbuild/javascript-transformer-worker.js +0 -154
  151. package/src/tools/esbuild/javascript-transformer.d.ts +0 -54
  152. package/src/tools/esbuild/javascript-transformer.js +0 -143
  153. package/src/tools/esbuild/license-extractor.d.ts +0 -25
  154. package/src/tools/esbuild/license-extractor.js +0 -158
  155. package/src/tools/esbuild/load-result-cache.d.ts +0 -21
  156. package/src/tools/esbuild/load-result-cache.js +0 -75
  157. package/src/tools/esbuild/profiling.d.ts +0 -11
  158. package/src/tools/esbuild/profiling.js +0 -78
  159. package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +0 -18
  160. package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +0 -44
  161. package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +0 -17
  162. package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +0 -73
  163. package/src/tools/esbuild/stylesheets/bundle-options.d.ts +0 -35
  164. package/src/tools/esbuild/stylesheets/bundle-options.js +0 -64
  165. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +0 -25
  166. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +0 -57
  167. package/src/tools/esbuild/stylesheets/css-language.d.ts +0 -9
  168. package/src/tools/esbuild/stylesheets/css-language.js +0 -15
  169. package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +0 -18
  170. package/src/tools/esbuild/stylesheets/css-resource-plugin.js +0 -107
  171. package/src/tools/esbuild/stylesheets/less-language.d.ts +0 -9
  172. package/src/tools/esbuild/stylesheets/less-language.js +0 -155
  173. package/src/tools/esbuild/stylesheets/sass-language.d.ts +0 -10
  174. package/src/tools/esbuild/stylesheets/sass-language.js +0 -185
  175. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +0 -58
  176. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +0 -282
  177. package/src/tools/esbuild/utils.d.ts +0 -41
  178. package/src/tools/esbuild/utils.js +0 -378
  179. package/src/tools/esbuild/virtual-module-plugin.d.ts +0 -33
  180. package/src/tools/esbuild/virtual-module-plugin.js +0 -43
  181. package/src/tools/esbuild/watcher.d.ts +0 -25
  182. package/src/tools/esbuild/watcher.js +0 -118
  183. package/src/tools/sass/lexer.d.ts +0 -18
  184. package/src/tools/sass/lexer.js +0 -161
  185. package/src/tools/sass/rebasing-importer.d.ts +0 -101
  186. package/src/tools/sass/rebasing-importer.js +0 -337
  187. package/src/tools/sass/sass-service.d.ts +0 -49
  188. package/src/tools/sass/sass-service.js +0 -213
  189. package/src/tools/sass/worker.d.ts +0 -8
  190. package/src/tools/sass/worker.js +0 -164
  191. package/src/tools/vite/angular-memory-plugin.d.ts +0 -24
  192. package/src/tools/vite/angular-memory-plugin.js +0 -268
  193. package/src/tools/vite/i18n-locale-plugin.d.ts +0 -18
  194. package/src/tools/vite/i18n-locale-plugin.js +0 -55
  195. package/src/typings.d.ts +0 -21
  196. package/src/utils/bundle-calculator.d.ts +0 -44
  197. package/src/utils/bundle-calculator.js +0 -302
  198. package/src/utils/check-port.d.ts +0 -8
  199. package/src/utils/check-port.js +0 -58
  200. package/src/utils/delete-output-dir.d.ts +0 -11
  201. package/src/utils/delete-output-dir.js +0 -46
  202. package/src/utils/i18n-options.d.ts +0 -40
  203. package/src/utils/i18n-options.js +0 -254
  204. package/src/utils/index-file/augment-index-html.d.ts +0 -40
  205. package/src/utils/index-file/augment-index-html.js +0 -238
  206. package/src/utils/index-file/html-rewriting-stream.d.ts +0 -11
  207. package/src/utils/index-file/html-rewriting-stream.js +0 -28
  208. package/src/utils/index-file/index-html-generator.d.ts +0 -47
  209. package/src/utils/index-file/index-html-generator.js +0 -119
  210. package/src/utils/index-file/inline-critical-css.d.ts +0 -24
  211. package/src/utils/index-file/inline-critical-css.js +0 -179
  212. package/src/utils/index-file/inline-fonts.d.ts +0 -23
  213. package/src/utils/index-file/inline-fonts.js +0 -267
  214. package/src/utils/index-file/style-nonce.d.ts +0 -12
  215. package/src/utils/index-file/style-nonce.js +0 -53
  216. package/src/utils/load-proxy-config.d.ts +0 -8
  217. package/src/utils/load-proxy-config.js +0 -192
  218. package/src/utils/load-translations.d.ts +0 -16
  219. package/src/utils/load-translations.js +0 -84
  220. package/src/utils/postcss-configuration.d.ts +0 -17
  221. package/src/utils/postcss-configuration.js +0 -86
  222. package/src/utils/purge-cache.d.ts +0 -10
  223. package/src/utils/purge-cache.js +0 -40
  224. package/src/utils/routes-extractor/extractor.d.ts +0 -15
  225. package/src/utils/routes-extractor/extractor.js +0 -97
  226. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +0 -18
  227. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -129
  228. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +0 -8
  229. package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +0 -13
  230. package/src/utils/server-rendering/fetch-patch.d.ts +0 -8
  231. package/src/utils/server-rendering/fetch-patch.js +0 -66
  232. package/src/utils/server-rendering/load-esm-from-memory.d.ts +0 -10
  233. package/src/utils/server-rendering/load-esm-from-memory.js +0 -26
  234. package/src/utils/server-rendering/main-bundle-exports.d.ts +0 -27
  235. package/src/utils/server-rendering/main-bundle-exports.js +0 -9
  236. package/src/utils/server-rendering/prerender.d.ts +0 -23
  237. package/src/utils/server-rendering/prerender.js +0 -192
  238. package/src/utils/server-rendering/render-page.d.ts +0 -26
  239. package/src/utils/server-rendering/render-page.js +0 -110
  240. package/src/utils/server-rendering/render-worker.d.ts +0 -22
  241. package/src/utils/server-rendering/render-worker.js +0 -30
  242. package/src/utils/server-rendering/routes-extractor-worker.d.ts +0 -21
  243. package/src/utils/server-rendering/routes-extractor-worker.js +0 -53
  244. package/src/utils/service-worker.d.ts +0 -25
  245. package/src/utils/service-worker.js +0 -211
  246. package/src/utils/supported-browsers.d.ts +0 -10
  247. package/src/utils/supported-browsers.js +0 -42
  248. package/src/utils/version.d.ts +0 -8
  249. package/src/utils/version.js +0 -59
@@ -1,57 +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.createCssInlineFontsPlugin = void 0;
11
- const inline_fonts_1 = require("../../../utils/index-file/inline-fonts");
12
- const load_result_cache_1 = require("../load-result-cache");
13
- /**
14
- * Creates an esbuild {@link Plugin} that inlines fonts imported via import-rule.
15
- * within the build configuration.
16
- */
17
- function createCssInlineFontsPlugin({ cache, cacheOptions, }) {
18
- return {
19
- name: 'angular-css-inline-fonts-plugin',
20
- setup(build) {
21
- const inlineFontsProcessor = new inline_fonts_1.InlineFontsProcessor({ cache: cacheOptions, minify: false });
22
- build.onResolve({ filter: /fonts\.googleapis\.com|use\.typekit\.net/ }, (args) => {
23
- // Only attempt to resolve import-rule tokens which only exist inside CSS.
24
- if (args.kind !== 'import-rule') {
25
- return null;
26
- }
27
- if (!inlineFontsProcessor.canInlineRequest(args.path)) {
28
- return null;
29
- }
30
- return {
31
- path: args.path,
32
- namespace: 'css-inline-fonts',
33
- };
34
- });
35
- build.onLoad({ filter: /./, namespace: 'css-inline-fonts' }, (0, load_result_cache_1.createCachedLoad)(cache, async (args) => {
36
- try {
37
- return {
38
- contents: await inlineFontsProcessor.processURL(args.path),
39
- loader: 'css',
40
- };
41
- }
42
- catch (error) {
43
- return {
44
- loader: 'css',
45
- errors: [
46
- {
47
- text: `Failed to inline external stylesheet '${args.path}'.`,
48
- detail: error,
49
- },
50
- ],
51
- };
52
- }
53
- }));
54
- },
55
- };
56
- }
57
- exports.createCssInlineFontsPlugin = createCssInlineFontsPlugin;
@@ -1,9 +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 { StylesheetLanguage } from './stylesheet-plugin-factory';
9
- export declare const CssStylesheetLanguage: Readonly<StylesheetLanguage>;
@@ -1,15 +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.CssStylesheetLanguage = void 0;
11
- exports.CssStylesheetLanguage = Object.freeze({
12
- name: 'css',
13
- componentFilter: /^css;/,
14
- fileFilter: /\.css$/,
15
- });
@@ -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 'esbuild';
9
- import { LoadResultCache } from '../load-result-cache';
10
- /**
11
- * Creates an esbuild {@link Plugin} that loads all CSS url token references using the
12
- * built-in esbuild `file` loader. A plugin is used to allow for all file extensions
13
- * and types to be supported without needing to manually specify all extensions
14
- * within the build configuration.
15
- *
16
- * @returns An esbuild {@link Plugin} instance.
17
- */
18
- export declare function createCssResourcePlugin(cache?: LoadResultCache): Plugin;
@@ -1,107 +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.createCssResourcePlugin = void 0;
11
- const promises_1 = require("node:fs/promises");
12
- const node_path_1 = require("node:path");
13
- const load_result_cache_1 = require("../load-result-cache");
14
- const CSS_RESOURCE_NAMESPACE = 'angular:css-resource';
15
- /**
16
- * Symbol marker used to indicate CSS resource resolution is being attempted.
17
- * This is used to prevent an infinite loop within the plugin's resolve hook.
18
- */
19
- const CSS_RESOURCE_RESOLUTION = Symbol('CSS_RESOURCE_RESOLUTION');
20
- /**
21
- * Creates an esbuild {@link Plugin} that loads all CSS url token references using the
22
- * built-in esbuild `file` loader. A plugin is used to allow for all file extensions
23
- * and types to be supported without needing to manually specify all extensions
24
- * within the build configuration.
25
- *
26
- * @returns An esbuild {@link Plugin} instance.
27
- */
28
- function createCssResourcePlugin(cache) {
29
- return {
30
- name: 'angular-css-resource',
31
- setup(build) {
32
- build.onResolve({ filter: /.*/ }, async (args) => {
33
- // Only attempt to resolve url tokens which only exist inside CSS.
34
- // Also, skip this plugin if already attempting to resolve the url-token.
35
- if (args.kind !== 'url-token' || args.pluginData?.[CSS_RESOURCE_RESOLUTION]) {
36
- return null;
37
- }
38
- // If root-relative, absolute or protocol relative url, mark as external to leave the
39
- // path/URL in place.
40
- if (/^((?:\w+:)?\/\/|data:|chrome:|#|\/)/.test(args.path)) {
41
- return {
42
- path: args.path,
43
- external: true,
44
- };
45
- }
46
- const { importer, kind, resolveDir, namespace, pluginData = {} } = args;
47
- pluginData[CSS_RESOURCE_RESOLUTION] = true;
48
- const result = await build.resolve(args.path, {
49
- importer,
50
- kind,
51
- namespace,
52
- pluginData,
53
- resolveDir,
54
- });
55
- if (result.errors.length) {
56
- const error = result.errors[0];
57
- if (args.path[0] === '~') {
58
- error.notes = [
59
- {
60
- location: null,
61
- text: 'You can remove the tilde and use a relative path to reference it, which should remove this error.',
62
- },
63
- ];
64
- }
65
- else if (args.path[0] === '^') {
66
- error.notes = [
67
- {
68
- location: null,
69
- text: 'You can remove the caret and add the path to the `externalDependencies` build option,' +
70
- ' which should remove this error.',
71
- },
72
- ];
73
- }
74
- const extension = importer && (0, node_path_1.extname)(importer);
75
- if (extension !== '.css') {
76
- error.notes.push({
77
- location: null,
78
- text: 'Preprocessor stylesheets may not show the exact file location of the error.',
79
- });
80
- }
81
- }
82
- // Return results that are not files since these are most likely specific to another plugin
83
- // and cannot be loaded by this plugin.
84
- if (result.namespace !== 'file') {
85
- return result;
86
- }
87
- // All file results are considered CSS resources and will be loaded via the file loader
88
- return {
89
- ...result,
90
- // Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).
91
- // This is only necessary for custom namespaces. esbuild will handle the file namespace.
92
- path: (0, node_path_1.relative)(build.initialOptions.absWorkingDir ?? '', result.path),
93
- namespace: CSS_RESOURCE_NAMESPACE,
94
- };
95
- });
96
- build.onLoad({ filter: /./, namespace: CSS_RESOURCE_NAMESPACE }, (0, load_result_cache_1.createCachedLoad)(cache, async (args) => {
97
- const resourcePath = (0, node_path_1.join)(build.initialOptions.absWorkingDir ?? '', args.path);
98
- return {
99
- contents: await (0, promises_1.readFile)(resourcePath),
100
- loader: 'file',
101
- watchFiles: [resourcePath],
102
- };
103
- }));
104
- },
105
- };
106
- }
107
- exports.createCssResourcePlugin = createCssResourcePlugin;
@@ -1,9 +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 { StylesheetLanguage } from './stylesheet-plugin-factory';
9
- export declare const LessStylesheetLanguage: Readonly<StylesheetLanguage>;
@@ -1,155 +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
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.LessStylesheetLanguage = void 0;
34
- const promises_1 = require("node:fs/promises");
35
- /**
36
- * The lazy-loaded instance of the less stylesheet preprocessor.
37
- * It is only imported and initialized if a less stylesheet is used.
38
- */
39
- let lessPreprocessor;
40
- function isLessException(error) {
41
- return !!error && typeof error === 'object' && 'column' in error;
42
- }
43
- exports.LessStylesheetLanguage = Object.freeze({
44
- name: 'less',
45
- componentFilter: /^less;/,
46
- fileFilter: /\.less$/,
47
- process(data, file, _, options, build) {
48
- return compileString(data, file, options, build.resolve.bind(build),
49
- /* unsafeInlineJavaScript */ false);
50
- },
51
- });
52
- async function compileString(data, filename, options, resolver, unsafeInlineJavaScript) {
53
- const less = (lessPreprocessor ??= (await Promise.resolve().then(() => __importStar(require('less')))).default);
54
- const resolverPlugin = {
55
- install({ FileManager }, pluginManager) {
56
- const resolverFileManager = new (class extends FileManager {
57
- supportsSync() {
58
- return false;
59
- }
60
- supports() {
61
- return true;
62
- }
63
- async loadFile(filename, currentDirectory, options, environment) {
64
- // Attempt direct loading as a relative path to avoid resolution overhead
65
- try {
66
- return await super.loadFile(filename, currentDirectory, options, environment);
67
- }
68
- catch (error) {
69
- // Attempt a full resolution if not found
70
- const fullResult = await resolver(filename, {
71
- kind: 'import-rule',
72
- resolveDir: currentDirectory,
73
- });
74
- if (fullResult.path) {
75
- return {
76
- filename: fullResult.path,
77
- contents: await (0, promises_1.readFile)(fullResult.path, 'utf-8'),
78
- };
79
- }
80
- // Otherwise error by throwing the failing direct result
81
- throw error;
82
- }
83
- }
84
- })();
85
- pluginManager.addFileManager(resolverFileManager);
86
- },
87
- };
88
- try {
89
- const result = await less.render(data, {
90
- filename,
91
- paths: options.includePaths,
92
- plugins: [resolverPlugin],
93
- rewriteUrls: 'all',
94
- javascriptEnabled: unsafeInlineJavaScript,
95
- sourceMap: options.sourcemap
96
- ? {
97
- sourceMapFileInline: true,
98
- outputSourceFiles: true,
99
- }
100
- : undefined,
101
- });
102
- return {
103
- contents: result.css,
104
- loader: 'css',
105
- watchFiles: [filename, ...result.imports],
106
- };
107
- }
108
- catch (error) {
109
- if (isLessException(error)) {
110
- const location = convertExceptionLocation(error);
111
- // Retry with a warning for less files requiring the deprecated inline JavaScript option
112
- if (error.message.includes('Inline JavaScript is not enabled.')) {
113
- const withJsResult = await compileString(data, filename, options, resolver,
114
- /* unsafeInlineJavaScript */ true);
115
- withJsResult.warnings = [
116
- {
117
- text: 'Deprecated inline execution of JavaScript has been enabled ("javascriptEnabled")',
118
- location,
119
- notes: [
120
- {
121
- location: null,
122
- text: 'JavaScript found within less stylesheets may be executed at build time. [https://lesscss.org/usage/#less-options]',
123
- },
124
- {
125
- location: null,
126
- text: 'Support for "javascriptEnabled" may be removed from the Angular CLI starting with Angular v19.',
127
- },
128
- ],
129
- },
130
- ];
131
- return withJsResult;
132
- }
133
- return {
134
- errors: [
135
- {
136
- text: error.message,
137
- location,
138
- },
139
- ],
140
- loader: 'css',
141
- watchFiles: location.file ? [filename, location.file] : [filename],
142
- };
143
- }
144
- throw error;
145
- }
146
- }
147
- function convertExceptionLocation(exception) {
148
- return {
149
- file: exception.filename,
150
- line: exception.line,
151
- column: exception.column,
152
- // Middle element represents the line containing the exception
153
- lineText: exception.extract && exception.extract[Math.trunc(exception.extract.length / 2)],
154
- };
155
- }
@@ -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 { StylesheetLanguage } from './stylesheet-plugin-factory';
9
- export declare function shutdownSassWorkerPool(): void;
10
- export declare const SassStylesheetLanguage: Readonly<StylesheetLanguage>;
@@ -1,185 +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
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.SassStylesheetLanguage = exports.shutdownSassWorkerPool = void 0;
34
- const node_path_1 = require("node:path");
35
- const node_url_1 = require("node:url");
36
- const cache_1 = require("../cache");
37
- let sassWorkerPool;
38
- let sassWorkerPoolPromise;
39
- function isSassException(error) {
40
- return !!error && typeof error === 'object' && 'sassMessage' in error;
41
- }
42
- function shutdownSassWorkerPool() {
43
- if (sassWorkerPool) {
44
- sassWorkerPool.close();
45
- sassWorkerPool = undefined;
46
- }
47
- else if (sassWorkerPoolPromise) {
48
- void sassWorkerPoolPromise.then(shutdownSassWorkerPool);
49
- }
50
- sassWorkerPoolPromise = undefined;
51
- }
52
- exports.shutdownSassWorkerPool = shutdownSassWorkerPool;
53
- exports.SassStylesheetLanguage = Object.freeze({
54
- name: 'sass',
55
- componentFilter: /^s[ac]ss;/,
56
- fileFilter: /\.s[ac]ss$/,
57
- process(data, file, format, options, build) {
58
- const syntax = format === 'sass' ? 'indented' : 'scss';
59
- const resolveUrl = async (url, options) => {
60
- let resolveDir = build.initialOptions.absWorkingDir;
61
- if (options.containingUrl) {
62
- resolveDir = (0, node_path_1.dirname)((0, node_url_1.fileURLToPath)(options.containingUrl));
63
- }
64
- const result = await build.resolve(url, {
65
- kind: 'import-rule',
66
- resolveDir,
67
- });
68
- return result;
69
- };
70
- return compileString(data, file, syntax, options, resolveUrl);
71
- },
72
- });
73
- function parsePackageName(url) {
74
- const parts = url.split('/');
75
- const hasScope = parts.length >= 2 && parts[0].startsWith('@');
76
- const [nameOrScope, nameOrFirstPath, ...pathPart] = parts;
77
- const packageName = hasScope ? `${nameOrScope}/${nameOrFirstPath}` : nameOrScope;
78
- return {
79
- packageName,
80
- get pathSegments() {
81
- return !hasScope && nameOrFirstPath ? [nameOrFirstPath, ...pathPart] : pathPart;
82
- },
83
- };
84
- }
85
- async function compileString(data, filePath, syntax, options, resolveUrl) {
86
- // Lazily load Sass when a Sass file is found
87
- if (sassWorkerPool === undefined) {
88
- if (sassWorkerPoolPromise === undefined) {
89
- sassWorkerPoolPromise = Promise.resolve().then(() => __importStar(require('../../sass/sass-service'))).then((sassService) => new sassService.SassWorkerImplementation(true));
90
- }
91
- sassWorkerPool = await sassWorkerPoolPromise;
92
- }
93
- // Cache is currently local to individual compile requests.
94
- // Caching follows Sass behavior where a given url will always resolve to the same value
95
- // regardless of its importer's path.
96
- // A null value indicates that the cached resolution attempt failed to find a location and
97
- // later stage resolution should be attempted. This avoids potentially expensive repeat
98
- // failing resolution attempts.
99
- const resolutionCache = new cache_1.MemoryCache();
100
- const packageRootCache = new cache_1.MemoryCache();
101
- const warnings = [];
102
- try {
103
- const { css, sourceMap, loadedUrls } = await sassWorkerPool.compileStringAsync(data, {
104
- url: (0, node_url_1.pathToFileURL)(filePath),
105
- style: 'expanded',
106
- syntax,
107
- loadPaths: options.includePaths,
108
- sourceMap: options.sourcemap,
109
- sourceMapIncludeSources: options.sourcemap,
110
- quietDeps: true,
111
- importers: [
112
- {
113
- findFileUrl: (url, options) => resolutionCache.getOrCreate(url, async () => {
114
- const result = await resolveUrl(url, options);
115
- if (result.path) {
116
- return (0, node_url_1.pathToFileURL)(result.path);
117
- }
118
- // Check for package deep imports
119
- const { packageName, pathSegments } = parsePackageName(url);
120
- // Caching package root locations is particularly beneficial for `@material/*` packages
121
- // which extensively use deep imports.
122
- const packageRoot = await packageRootCache.getOrCreate(packageName, async () => {
123
- // Use the required presence of a package root `package.json` file to resolve the location
124
- const packageResult = await resolveUrl(packageName + '/package.json', options);
125
- return packageResult.path ? (0, node_path_1.dirname)(packageResult.path) : null;
126
- });
127
- // Package not found could be because of an error or the specifier is intended to be found
128
- // via a later stage of the resolution process (`loadPaths`, etc.).
129
- // Errors are reported after the full completion of the resolution process. Exceptions for
130
- // not found packages should not be raised here.
131
- if (packageRoot) {
132
- return (0, node_url_1.pathToFileURL)((0, node_path_1.join)(packageRoot, ...pathSegments));
133
- }
134
- // Not found
135
- return null;
136
- }),
137
- },
138
- ],
139
- logger: {
140
- warn: (text, { deprecation, span }) => {
141
- warnings.push({
142
- text: deprecation ? 'Deprecation' : text,
143
- location: span && {
144
- file: span.url && (0, node_url_1.fileURLToPath)(span.url),
145
- lineText: span.context,
146
- // Sass line numbers are 0-based while esbuild's are 1-based
147
- line: span.start.line + 1,
148
- column: span.start.column,
149
- },
150
- notes: deprecation ? [{ text }] : undefined,
151
- });
152
- },
153
- },
154
- });
155
- return {
156
- loader: 'css',
157
- contents: sourceMap ? `${css}\n${sourceMapToUrlComment(sourceMap, (0, node_path_1.dirname)(filePath))}` : css,
158
- watchFiles: loadedUrls.map((url) => (0, node_url_1.fileURLToPath)(url)),
159
- warnings,
160
- };
161
- }
162
- catch (error) {
163
- if (isSassException(error)) {
164
- const fileWithError = error.span.url ? (0, node_url_1.fileURLToPath)(error.span.url) : undefined;
165
- return {
166
- loader: 'css',
167
- errors: [
168
- {
169
- text: error.message,
170
- },
171
- ],
172
- warnings,
173
- watchFiles: fileWithError ? [filePath, fileWithError] : [filePath],
174
- };
175
- }
176
- throw error;
177
- }
178
- }
179
- function sourceMapToUrlComment(sourceMap, root) {
180
- // Remove `file` protocol from all sourcemap sources and adjust to be relative to the input file.
181
- // This allows esbuild to correctly process the paths.
182
- sourceMap.sources = sourceMap.sources.map((source) => (0, node_path_1.relative)(root, (0, node_url_1.fileURLToPath)(source)));
183
- const urlSourceMap = Buffer.from(JSON.stringify(sourceMap), 'utf-8').toString('base64');
184
- return `/*# sourceMappingURL=data:application/json;charset=utf-8;base64,${urlSourceMap} */`;
185
- }
@@ -1,58 +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 { OnLoadResult, Plugin, PluginBuild } from 'esbuild';
9
- import type { PostcssConfiguration } from '../../../utils/postcss-configuration';
10
- import { LoadResultCache } from '../load-result-cache';
11
- /**
12
- * An object containing the plugin options to use when processing stylesheets.
13
- */
14
- export interface StylesheetPluginOptions {
15
- /**
16
- * Controls the use and creation of sourcemaps when processing the stylesheets.
17
- * If true, sourcemap processing is enabled; if false, disabled.
18
- */
19
- sourcemap: boolean;
20
- /**
21
- * An optional array of paths that will be searched for stylesheets if the default
22
- * resolution process for the stylesheet language does not succeed.
23
- */
24
- includePaths?: string[];
25
- /**
26
- * Optional component data for any inline styles from Component decorator `styles` fields.
27
- * The key is an internal angular resource URI and the value is the stylesheet content.
28
- */
29
- inlineComponentData?: Record<string, string>;
30
- /**
31
- * Optional information used to load and configure Tailwind CSS. If present, the postcss
32
- * will be added to the stylesheet processing with the Tailwind plugin setup as provided
33
- * by the configuration file.
34
- */
35
- tailwindConfiguration?: {
36
- file: string;
37
- package: string;
38
- };
39
- /**
40
- * Optional configuration object for custom postcss usage. If present, postcss will be
41
- * initialized and used for every stylesheet. This overrides the tailwind integration
42
- * and any tailwind usage must be manually configured in the custom postcss usage.
43
- */
44
- postcssConfiguration?: PostcssConfiguration;
45
- }
46
- export interface StylesheetLanguage {
47
- name: string;
48
- componentFilter: RegExp;
49
- fileFilter: RegExp;
50
- process?(data: string, file: string, format: string, options: StylesheetPluginOptions, build: PluginBuild): OnLoadResult | Promise<OnLoadResult>;
51
- }
52
- export declare class StylesheetPluginFactory {
53
- private readonly options;
54
- private readonly cache?;
55
- private postcssProcessor?;
56
- constructor(options: StylesheetPluginOptions, cache?: LoadResultCache | undefined);
57
- create(language: Readonly<StylesheetLanguage>): Plugin;
58
- }