@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,161 +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.findUrls = void 0;
11
- // TODO: Combine everything into a single pass lexer
12
- /**
13
- * Determines if a unicode code point is a CSS whitespace character.
14
- * @param code The unicode code point to test.
15
- * @returns true, if the code point is CSS whitespace; false, otherwise.
16
- */
17
- function isWhitespace(code) {
18
- // Based on https://www.w3.org/TR/css-syntax-3/#whitespace
19
- switch (code) {
20
- case 0x0009: // tab
21
- case 0x0020: // space
22
- case 0x000a: // line feed
23
- case 0x000c: // form feed
24
- case 0x000d: // carriage return
25
- return true;
26
- default:
27
- return false;
28
- }
29
- }
30
- /**
31
- * Scans a CSS or Sass file and locates all valid url function values as defined by the
32
- * syntax specification.
33
- * @param contents A string containing a CSS or Sass file to scan.
34
- * @returns An iterable that yields each CSS url function value found.
35
- */
36
- function* findUrls(contents) {
37
- let pos = 0;
38
- let width = 1;
39
- let current = -1;
40
- const next = () => {
41
- pos += width;
42
- current = contents.codePointAt(pos) ?? -1;
43
- width = current > 0xffff ? 2 : 1;
44
- return current;
45
- };
46
- // Based on https://www.w3.org/TR/css-syntax-3/#consume-ident-like-token
47
- while ((pos = contents.indexOf('url(', pos)) !== -1) {
48
- // Set to position of the (
49
- pos += 3;
50
- width = 1;
51
- // Consume all leading whitespace
52
- while (isWhitespace(next())) {
53
- /* empty */
54
- }
55
- // Initialize URL state
56
- const url = { start: pos, end: -1, value: '' };
57
- let complete = false;
58
- // If " or ', then consume the value as a string
59
- if (current === 0x0022 || current === 0x0027) {
60
- const ending = current;
61
- // Based on https://www.w3.org/TR/css-syntax-3/#consume-string-token
62
- while (!complete) {
63
- switch (next()) {
64
- case -1: // EOF
65
- return;
66
- case 0x000a: // line feed
67
- case 0x000c: // form feed
68
- case 0x000d: // carriage return
69
- // Invalid
70
- complete = true;
71
- break;
72
- case 0x005c: // \ -- character escape
73
- // If not EOF or newline, add the character after the escape
74
- switch (next()) {
75
- case -1:
76
- return;
77
- case 0x000a: // line feed
78
- case 0x000c: // form feed
79
- case 0x000d: // carriage return
80
- // Skip when inside a string
81
- break;
82
- default:
83
- // TODO: Handle hex escape codes
84
- url.value += String.fromCodePoint(current);
85
- break;
86
- }
87
- break;
88
- case ending:
89
- // Full string position should include the quotes for replacement
90
- url.end = pos + 1;
91
- complete = true;
92
- yield url;
93
- break;
94
- default:
95
- url.value += String.fromCodePoint(current);
96
- break;
97
- }
98
- }
99
- next();
100
- continue;
101
- }
102
- // Based on https://www.w3.org/TR/css-syntax-3/#consume-url-token
103
- while (!complete) {
104
- switch (current) {
105
- case -1: // EOF
106
- return;
107
- case 0x0022: // "
108
- case 0x0027: // '
109
- case 0x0028: // (
110
- // Invalid
111
- complete = true;
112
- break;
113
- case 0x0029: // )
114
- // URL is valid and complete
115
- url.end = pos;
116
- complete = true;
117
- break;
118
- case 0x005c: // \ -- character escape
119
- // If not EOF or newline, add the character after the escape
120
- switch (next()) {
121
- case -1: // EOF
122
- return;
123
- case 0x000a: // line feed
124
- case 0x000c: // form feed
125
- case 0x000d: // carriage return
126
- // Invalid
127
- complete = true;
128
- break;
129
- default:
130
- // TODO: Handle hex escape codes
131
- url.value += String.fromCodePoint(current);
132
- break;
133
- }
134
- break;
135
- default:
136
- if (isWhitespace(current)) {
137
- while (isWhitespace(next())) {
138
- /* empty */
139
- }
140
- // Unescaped whitespace is only valid before the closing )
141
- if (current === 0x0029) {
142
- // URL is valid
143
- url.end = pos;
144
- }
145
- complete = true;
146
- }
147
- else {
148
- // Add the character to the url value
149
- url.value += String.fromCodePoint(current);
150
- }
151
- break;
152
- }
153
- next();
154
- }
155
- // An end position indicates a URL was found
156
- if (url.end !== -1) {
157
- yield url;
158
- }
159
- }
160
- }
161
- exports.findUrls = findUrls;
@@ -1,101 +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 { RawSourceMap } from '@ampproject/remapping';
9
- import type { CanonicalizeContext, Importer, ImporterResult } from 'sass';
10
- /**
11
- * A preprocessed cache entry for the files and directories within a previously searched
12
- * directory when performing Sass import resolution.
13
- */
14
- export interface DirectoryEntry {
15
- files: Set<string>;
16
- directories: Set<string>;
17
- }
18
- /**
19
- * A Sass Importer base class that provides the load logic to rebase all `url()` functions
20
- * within a stylesheet. The rebasing will ensure that the URLs in the output of the Sass compiler
21
- * reflect the final filesystem location of the output CSS file.
22
- *
23
- * This class provides the core of the rebasing functionality. To ensure that each file is processed
24
- * by this importer's load implementation, the Sass compiler requires the importer's canonicalize
25
- * function to return a non-null value with the resolved location of the requested stylesheet.
26
- * Concrete implementations of this class must provide this canonicalize functionality for rebasing
27
- * to be effective.
28
- */
29
- declare abstract class UrlRebasingImporter implements Importer<'sync'> {
30
- private entryDirectory;
31
- private rebaseSourceMaps?;
32
- /**
33
- * @param entryDirectory The directory of the entry stylesheet that was passed to the Sass compiler.
34
- * @param rebaseSourceMaps When provided, rebased files will have an intermediate sourcemap added to the Map
35
- * which can be used to generate a final sourcemap that contains original sources.
36
- */
37
- constructor(entryDirectory: string, rebaseSourceMaps?: Map<string, RawSourceMap> | undefined);
38
- abstract canonicalize(url: string, options: {
39
- fromImport: boolean;
40
- }): URL | null;
41
- load(canonicalUrl: URL): ImporterResult | null;
42
- }
43
- /**
44
- * Provides the Sass importer logic to resolve relative stylesheet imports via both import and use rules
45
- * and also rebase any `url()` function usage within those stylesheets. The rebasing will ensure that
46
- * the URLs in the output of the Sass compiler reflect the final filesystem location of the output CSS file.
47
- */
48
- export declare class RelativeUrlRebasingImporter extends UrlRebasingImporter {
49
- private directoryCache;
50
- constructor(entryDirectory: string, directoryCache?: Map<string, DirectoryEntry>, rebaseSourceMaps?: Map<string, RawSourceMap>);
51
- canonicalize(url: string, options: {
52
- fromImport: boolean;
53
- }): URL | null;
54
- /**
55
- * Attempts to resolve a provided URL to a stylesheet file using the Sass compiler's resolution algorithm.
56
- * Based on https://github.com/sass/dart-sass/blob/44d6bb6ac72fe6b93f5bfec371a1fffb18e6b76d/lib/src/importer/utils.dart
57
- * @param url The file protocol URL to resolve.
58
- * @param fromImport If true, URL was from an import rule; otherwise from a use rule.
59
- * @param checkDirectory If true, try checking for a directory with the base name containing an index file.
60
- * @returns A full resolved URL of the stylesheet file or `null` if not found.
61
- */
62
- private resolveImport;
63
- /**
64
- * Checks an array of potential stylesheet files to determine if there is a valid
65
- * stylesheet file. More than one discovered file may indicate an error.
66
- * @param found An array of discovered stylesheet files.
67
- * @returns A fully resolved path for a stylesheet file or `null` if not found.
68
- * @throws If there are ambiguous files discovered.
69
- */
70
- private checkFound;
71
- }
72
- /**
73
- * Provides the Sass importer logic to resolve module (npm package) stylesheet imports via both import and
74
- * use rules and also rebase any `url()` function usage within those stylesheets. The rebasing will ensure that
75
- * the URLs in the output of the Sass compiler reflect the final filesystem location of the output CSS file.
76
- */
77
- export declare class ModuleUrlRebasingImporter extends RelativeUrlRebasingImporter {
78
- private finder;
79
- constructor(entryDirectory: string, directoryCache: Map<string, DirectoryEntry>, rebaseSourceMaps: Map<string, RawSourceMap> | undefined, finder: (specifier: string, options: CanonicalizeContext) => URL | null);
80
- canonicalize(url: string, options: CanonicalizeContext): URL | null;
81
- }
82
- /**
83
- * Provides the Sass importer logic to resolve load paths located stylesheet imports via both import and
84
- * use rules and also rebase any `url()` function usage within those stylesheets. The rebasing will ensure that
85
- * the URLs in the output of the Sass compiler reflect the final filesystem location of the output CSS file.
86
- */
87
- export declare class LoadPathsUrlRebasingImporter extends RelativeUrlRebasingImporter {
88
- private loadPaths;
89
- constructor(entryDirectory: string, directoryCache: Map<string, DirectoryEntry>, rebaseSourceMaps: Map<string, RawSourceMap> | undefined, loadPaths: Iterable<string>);
90
- canonicalize(url: string, options: {
91
- fromImport: boolean;
92
- }): URL | null;
93
- }
94
- /**
95
- * Workaround for Sass not calling instance methods with `this`.
96
- * The `canonicalize` and `load` methods will be bound to the class instance.
97
- * @param importer A Sass importer to bind.
98
- * @returns The bound Sass importer.
99
- */
100
- export declare function sassBindWorkaround<T extends Importer>(importer: T): T;
101
- export {};
@@ -1,337 +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.sassBindWorkaround = exports.LoadPathsUrlRebasingImporter = exports.ModuleUrlRebasingImporter = exports.RelativeUrlRebasingImporter = void 0;
14
- const magic_string_1 = __importDefault(require("magic-string"));
15
- const node_fs_1 = require("node:fs");
16
- const node_path_1 = require("node:path");
17
- const node_url_1 = require("node:url");
18
- const lexer_1 = require("./lexer");
19
- /**
20
- * Ensures that a bare specifier URL path that is intended to be treated as
21
- * a relative path has a leading `./` or `../` prefix.
22
- *
23
- * @param url A bare specifier URL path that should be considered relative.
24
- * @returns
25
- */
26
- function ensureRelative(url) {
27
- // Empty
28
- if (!url) {
29
- return url;
30
- }
31
- // Already relative
32
- if (url[0] === '.' && (url[1] === '/' || (url[1] === '.' && url[2] === '/'))) {
33
- return url;
34
- }
35
- // Needs prefix
36
- return './' + url;
37
- }
38
- /**
39
- * A Sass Importer base class that provides the load logic to rebase all `url()` functions
40
- * within a stylesheet. The rebasing will ensure that the URLs in the output of the Sass compiler
41
- * reflect the final filesystem location of the output CSS file.
42
- *
43
- * This class provides the core of the rebasing functionality. To ensure that each file is processed
44
- * by this importer's load implementation, the Sass compiler requires the importer's canonicalize
45
- * function to return a non-null value with the resolved location of the requested stylesheet.
46
- * Concrete implementations of this class must provide this canonicalize functionality for rebasing
47
- * to be effective.
48
- */
49
- class UrlRebasingImporter {
50
- entryDirectory;
51
- rebaseSourceMaps;
52
- /**
53
- * @param entryDirectory The directory of the entry stylesheet that was passed to the Sass compiler.
54
- * @param rebaseSourceMaps When provided, rebased files will have an intermediate sourcemap added to the Map
55
- * which can be used to generate a final sourcemap that contains original sources.
56
- */
57
- constructor(entryDirectory, rebaseSourceMaps) {
58
- this.entryDirectory = entryDirectory;
59
- this.rebaseSourceMaps = rebaseSourceMaps;
60
- }
61
- load(canonicalUrl) {
62
- const stylesheetPath = (0, node_url_1.fileURLToPath)(canonicalUrl);
63
- const stylesheetDirectory = (0, node_path_1.dirname)(stylesheetPath);
64
- let contents = (0, node_fs_1.readFileSync)(stylesheetPath, 'utf-8');
65
- // Rebase any URLs that are found
66
- let updatedContents;
67
- for (const { start, end, value } of (0, lexer_1.findUrls)(contents)) {
68
- // Skip if value is empty or Webpack-specific prefix
69
- if (value.length === 0 || value[0] === '~' || value[0] === '^') {
70
- continue;
71
- }
72
- // Skip if value is a Sass variable.
73
- // Sass variable usage either starts with a `$` or contains a namespace and a `.$`
74
- if (value[0] === '$' || /^\w+\.\$/.test(value)) {
75
- continue;
76
- }
77
- // Skip if root-relative, absolute or protocol relative url
78
- if (/^((?:\w+:)?\/\/|data:|chrome:|#|\/)/.test(value)) {
79
- continue;
80
- }
81
- const rebasedPath = (0, node_path_1.relative)(this.entryDirectory, (0, node_path_1.join)(stylesheetDirectory, value));
82
- // Normalize path separators and escape characters
83
- // https://developer.mozilla.org/en-US/docs/Web/CSS/url#syntax
84
- const rebasedUrl = ensureRelative(rebasedPath.replace(/\\/g, '/').replace(/[()\s'"]/g, '\\$&'));
85
- updatedContents ??= new magic_string_1.default(contents);
86
- // Always quote the URL to avoid potential downstream parsing problems
87
- updatedContents.update(start, end, `"${rebasedUrl}"`);
88
- }
89
- if (updatedContents) {
90
- contents = updatedContents.toString();
91
- if (this.rebaseSourceMaps) {
92
- // Generate an intermediate source map for the rebasing changes
93
- const map = updatedContents.generateMap({
94
- hires: 'boundary',
95
- includeContent: true,
96
- source: canonicalUrl.href,
97
- });
98
- this.rebaseSourceMaps.set(canonicalUrl.href, map);
99
- }
100
- }
101
- let syntax;
102
- switch ((0, node_path_1.extname)(stylesheetPath).toLowerCase()) {
103
- case '.css':
104
- syntax = 'css';
105
- break;
106
- case '.sass':
107
- syntax = 'indented';
108
- break;
109
- default:
110
- syntax = 'scss';
111
- break;
112
- }
113
- return {
114
- contents,
115
- syntax,
116
- sourceMapUrl: canonicalUrl,
117
- };
118
- }
119
- }
120
- /**
121
- * Provides the Sass importer logic to resolve relative stylesheet imports via both import and use rules
122
- * and also rebase any `url()` function usage within those stylesheets. The rebasing will ensure that
123
- * the URLs in the output of the Sass compiler reflect the final filesystem location of the output CSS file.
124
- */
125
- class RelativeUrlRebasingImporter extends UrlRebasingImporter {
126
- directoryCache;
127
- constructor(entryDirectory, directoryCache = new Map(), rebaseSourceMaps) {
128
- super(entryDirectory, rebaseSourceMaps);
129
- this.directoryCache = directoryCache;
130
- }
131
- canonicalize(url, options) {
132
- return this.resolveImport(url, options.fromImport, true);
133
- }
134
- /**
135
- * Attempts to resolve a provided URL to a stylesheet file using the Sass compiler's resolution algorithm.
136
- * Based on https://github.com/sass/dart-sass/blob/44d6bb6ac72fe6b93f5bfec371a1fffb18e6b76d/lib/src/importer/utils.dart
137
- * @param url The file protocol URL to resolve.
138
- * @param fromImport If true, URL was from an import rule; otherwise from a use rule.
139
- * @param checkDirectory If true, try checking for a directory with the base name containing an index file.
140
- * @returns A full resolved URL of the stylesheet file or `null` if not found.
141
- */
142
- resolveImport(url, fromImport, checkDirectory) {
143
- let stylesheetPath;
144
- try {
145
- stylesheetPath = (0, node_url_1.fileURLToPath)(url);
146
- }
147
- catch {
148
- // Only file protocol URLs are supported by this importer
149
- return null;
150
- }
151
- const directory = (0, node_path_1.dirname)(stylesheetPath);
152
- const extension = (0, node_path_1.extname)(stylesheetPath);
153
- const hasStyleExtension = extension === '.scss' || extension === '.sass' || extension === '.css';
154
- // Remove the style extension if present to allow adding the `.import` suffix
155
- const filename = (0, node_path_1.basename)(stylesheetPath, hasStyleExtension ? extension : undefined);
156
- const importPotentials = new Set();
157
- const defaultPotentials = new Set();
158
- if (hasStyleExtension) {
159
- if (fromImport) {
160
- importPotentials.add(filename + '.import' + extension);
161
- importPotentials.add('_' + filename + '.import' + extension);
162
- }
163
- defaultPotentials.add(filename + extension);
164
- defaultPotentials.add('_' + filename + extension);
165
- }
166
- else {
167
- if (fromImport) {
168
- importPotentials.add(filename + '.import.scss');
169
- importPotentials.add(filename + '.import.sass');
170
- importPotentials.add(filename + '.import.css');
171
- importPotentials.add('_' + filename + '.import.scss');
172
- importPotentials.add('_' + filename + '.import.sass');
173
- importPotentials.add('_' + filename + '.import.css');
174
- }
175
- defaultPotentials.add(filename + '.scss');
176
- defaultPotentials.add(filename + '.sass');
177
- defaultPotentials.add(filename + '.css');
178
- defaultPotentials.add('_' + filename + '.scss');
179
- defaultPotentials.add('_' + filename + '.sass');
180
- defaultPotentials.add('_' + filename + '.css');
181
- }
182
- let foundDefaults;
183
- let foundImports;
184
- let hasPotentialIndex = false;
185
- let cachedEntries = this.directoryCache.get(directory);
186
- if (cachedEntries) {
187
- // If there is a preprocessed cache of the directory, perform an intersection of the potentials
188
- // and the directory files.
189
- const { files, directories } = cachedEntries;
190
- foundDefaults = [...defaultPotentials].filter((potential) => files.has(potential));
191
- foundImports = [...importPotentials].filter((potential) => files.has(potential));
192
- hasPotentialIndex = checkDirectory && !hasStyleExtension && directories.has(filename);
193
- }
194
- else {
195
- // If no preprocessed cache exists, get the entries from the file system and, while searching,
196
- // generate the cache for later requests.
197
- let entries;
198
- try {
199
- entries = (0, node_fs_1.readdirSync)(directory, { withFileTypes: true });
200
- }
201
- catch {
202
- return null;
203
- }
204
- foundDefaults = [];
205
- foundImports = [];
206
- cachedEntries = { files: new Set(), directories: new Set() };
207
- for (const entry of entries) {
208
- let isDirectory;
209
- let isFile;
210
- if (entry.isSymbolicLink()) {
211
- const stats = (0, node_fs_1.statSync)((0, node_path_1.join)(entry.path, entry.name));
212
- isDirectory = stats.isDirectory();
213
- isFile = stats.isFile();
214
- }
215
- else {
216
- isDirectory = entry.isDirectory();
217
- isFile = entry.isFile();
218
- }
219
- if (isDirectory) {
220
- cachedEntries.directories.add(entry.name);
221
- // Record if the name should be checked as a directory with an index file
222
- if (checkDirectory && !hasStyleExtension && entry.name === filename) {
223
- hasPotentialIndex = true;
224
- }
225
- }
226
- if (!isFile) {
227
- continue;
228
- }
229
- cachedEntries.files.add(entry.name);
230
- if (importPotentials.has(entry.name)) {
231
- foundImports.push(entry.name);
232
- }
233
- if (defaultPotentials.has(entry.name)) {
234
- foundDefaults.push(entry.name);
235
- }
236
- }
237
- this.directoryCache.set(directory, cachedEntries);
238
- }
239
- // `foundImports` will only contain elements if `options.fromImport` is true
240
- const result = this.checkFound(foundImports) ?? this.checkFound(foundDefaults);
241
- if (result !== null) {
242
- return (0, node_url_1.pathToFileURL)((0, node_path_1.join)(directory, result));
243
- }
244
- if (hasPotentialIndex) {
245
- // Check for index files using filename as a directory
246
- return this.resolveImport(url + '/index', fromImport, false);
247
- }
248
- return null;
249
- }
250
- /**
251
- * Checks an array of potential stylesheet files to determine if there is a valid
252
- * stylesheet file. More than one discovered file may indicate an error.
253
- * @param found An array of discovered stylesheet files.
254
- * @returns A fully resolved path for a stylesheet file or `null` if not found.
255
- * @throws If there are ambiguous files discovered.
256
- */
257
- checkFound(found) {
258
- if (found.length === 0) {
259
- // Not found
260
- return null;
261
- }
262
- // More than one found file may be an error
263
- if (found.length > 1) {
264
- // Presence of CSS files alongside a Sass file does not cause an error
265
- const foundWithoutCss = found.filter((element) => (0, node_path_1.extname)(element) !== '.css');
266
- // If the length is zero then there are two or more css files
267
- // If the length is more than one than there are two or more sass/scss files
268
- if (foundWithoutCss.length !== 1) {
269
- throw new Error('Ambiguous import detected.');
270
- }
271
- // Return the non-CSS file (sass/scss files have priority)
272
- // https://github.com/sass/dart-sass/blob/44d6bb6ac72fe6b93f5bfec371a1fffb18e6b76d/lib/src/importer/utils.dart#L44-L47
273
- return foundWithoutCss[0];
274
- }
275
- return found[0];
276
- }
277
- }
278
- exports.RelativeUrlRebasingImporter = RelativeUrlRebasingImporter;
279
- /**
280
- * Provides the Sass importer logic to resolve module (npm package) stylesheet imports via both import and
281
- * use rules and also rebase any `url()` function usage within those stylesheets. The rebasing will ensure that
282
- * the URLs in the output of the Sass compiler reflect the final filesystem location of the output CSS file.
283
- */
284
- class ModuleUrlRebasingImporter extends RelativeUrlRebasingImporter {
285
- finder;
286
- constructor(entryDirectory, directoryCache, rebaseSourceMaps, finder) {
287
- super(entryDirectory, directoryCache, rebaseSourceMaps);
288
- this.finder = finder;
289
- }
290
- canonicalize(url, options) {
291
- if (url.startsWith('file://')) {
292
- return super.canonicalize(url, options);
293
- }
294
- let result = this.finder(url, options);
295
- result &&= super.canonicalize(result.href, options);
296
- return result;
297
- }
298
- }
299
- exports.ModuleUrlRebasingImporter = ModuleUrlRebasingImporter;
300
- /**
301
- * Provides the Sass importer logic to resolve load paths located stylesheet imports via both import and
302
- * use rules and also rebase any `url()` function usage within those stylesheets. The rebasing will ensure that
303
- * the URLs in the output of the Sass compiler reflect the final filesystem location of the output CSS file.
304
- */
305
- class LoadPathsUrlRebasingImporter extends RelativeUrlRebasingImporter {
306
- loadPaths;
307
- constructor(entryDirectory, directoryCache, rebaseSourceMaps, loadPaths) {
308
- super(entryDirectory, directoryCache, rebaseSourceMaps);
309
- this.loadPaths = loadPaths;
310
- }
311
- canonicalize(url, options) {
312
- if (url.startsWith('file://')) {
313
- return super.canonicalize(url, options);
314
- }
315
- let result = null;
316
- for (const loadPath of this.loadPaths) {
317
- result = super.canonicalize((0, node_url_1.pathToFileURL)((0, node_path_1.join)(loadPath, url)).href, options);
318
- if (result !== null) {
319
- break;
320
- }
321
- }
322
- return result;
323
- }
324
- }
325
- exports.LoadPathsUrlRebasingImporter = LoadPathsUrlRebasingImporter;
326
- /**
327
- * Workaround for Sass not calling instance methods with `this`.
328
- * The `canonicalize` and `load` methods will be bound to the class instance.
329
- * @param importer A Sass importer to bind.
330
- * @returns The bound Sass importer.
331
- */
332
- function sassBindWorkaround(importer) {
333
- importer.canonicalize = importer.canonicalize.bind(importer);
334
- importer.load = importer.load.bind(importer);
335
- return importer;
336
- }
337
- exports.sassBindWorkaround = sassBindWorkaround;
@@ -1,49 +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 { CompileResult, StringOptions } from 'sass';
9
- /**
10
- * A Sass renderer implementation that provides an interface that can be used by Webpack's
11
- * `sass-loader`. The implementation uses a Worker thread to perform the Sass rendering
12
- * with the `dart-sass` package. The `dart-sass` synchronous render function is used within
13
- * the worker which can be up to two times faster than the asynchronous variant.
14
- */
15
- export declare class SassWorkerImplementation {
16
- private rebase;
17
- private readonly workers;
18
- private readonly availableWorkers;
19
- private readonly requests;
20
- private readonly workerPath;
21
- private idCounter;
22
- private nextWorkerIndex;
23
- constructor(rebase?: boolean);
24
- /**
25
- * Provides information about the Sass implementation.
26
- * This mimics enough of the `dart-sass` value to be used with the `sass-loader`.
27
- */
28
- get info(): string;
29
- /**
30
- * The synchronous render function is not used by the `sass-loader`.
31
- */
32
- compileString(): never;
33
- /**
34
- * Asynchronously request a Sass stylesheet to be renderered.
35
- *
36
- * @param source The contents to compile.
37
- * @param options The `dart-sass` options to use when rendering the stylesheet.
38
- */
39
- compileStringAsync(source: string, options: StringOptions<'async'>): Promise<CompileResult>;
40
- /**
41
- * Shutdown the Sass render worker.
42
- * Executing this method will stop any pending render requests.
43
- */
44
- close(): void;
45
- private createWorker;
46
- private processImporters;
47
- private createRequest;
48
- private isFileImporter;
49
- }