@angular-devkit/build-angular 17.1.0-next.1 → 17.1.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/package.json +18 -18
  2. package/src/builders/application/build-action.d.ts +4 -3
  3. package/src/builders/application/build-action.js +24 -14
  4. package/src/builders/application/execute-build.js +3 -3
  5. package/src/builders/application/index.d.ts +20 -10
  6. package/src/builders/application/index.js +38 -26
  7. package/src/builders/application/options.d.ts +11 -3
  8. package/src/builders/application/options.js +39 -26
  9. package/src/builders/application/schema.d.ts +32 -2
  10. package/src/builders/application/schema.json +40 -2
  11. package/src/builders/browser-esbuild/builder-status-warnings.js +1 -3
  12. package/src/builders/browser-esbuild/index.js +8 -4
  13. package/src/builders/dev-server/builder.js +5 -0
  14. package/src/builders/dev-server/vite-server.js +16 -16
  15. package/src/builders/karma/index.js +4 -1
  16. package/src/builders/karma/schema.d.ts +6 -2
  17. package/src/builders/karma/schema.json +12 -2
  18. package/src/builders/ssr-dev-server/index.js +17 -31
  19. package/src/tools/esbuild/angular/angular-host.js +7 -1
  20. package/src/tools/esbuild/angular/compiler-plugin.js +11 -27
  21. package/src/tools/esbuild/angular/component-stylesheets.d.ts +3 -6
  22. package/src/tools/esbuild/angular/component-stylesheets.js +42 -47
  23. package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +2 -1
  24. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +16 -16
  25. package/src/tools/esbuild/angular/source-file-cache.js +0 -1
  26. package/src/tools/esbuild/bundler-context.d.ts +1 -1
  27. package/src/tools/esbuild/bundler-context.js +18 -2
  28. package/src/tools/esbuild/compiler-plugin-options.js +5 -3
  29. package/src/tools/esbuild/global-styles.js +4 -2
  30. package/src/tools/esbuild/index-html-generator.js +3 -1
  31. package/src/tools/esbuild/stylesheets/bundle-options.d.ts +4 -1
  32. package/src/tools/esbuild/stylesheets/bundle-options.js +11 -6
  33. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +25 -0
  34. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +57 -0
  35. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +9 -1
  36. package/src/tools/esbuild/utils.d.ts +2 -2
  37. package/src/tools/esbuild/utils.js +61 -74
  38. package/src/tools/esbuild/watcher.js +56 -121
  39. package/src/utils/check-port.js +15 -29
  40. package/src/utils/delete-output-dir.d.ts +1 -1
  41. package/src/utils/delete-output-dir.js +11 -2
  42. package/src/utils/index-file/index-html-generator.js +15 -28
  43. package/src/utils/index-file/inline-fonts.d.ts +6 -1
  44. package/src/utils/index-file/inline-fonts.js +30 -14
  45. package/src/utils/index.d.ts +1 -0
  46. package/src/utils/index.js +1 -0
  47. package/src/{builders/dev-server → utils}/load-proxy-config.js +2 -2
  48. package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.js +6 -5
  49. package/src/tools/esbuild/normalize-path.d.ts +0 -8
  50. package/src/tools/esbuild/normalize-path.js +0 -22
  51. /package/src/{builders/dev-server → utils}/load-proxy-config.d.ts +0 -0
@@ -114,7 +114,7 @@ class InlineFontsProcessor {
114
114
  if (!url) {
115
115
  continue;
116
116
  }
117
- const content = await this.processHref(url);
117
+ const content = await this.processURL(url);
118
118
  if (content === undefined) {
119
119
  continue;
120
120
  }
@@ -195,7 +195,16 @@ class InlineFontsProcessor {
195
195
  .get(url, {
196
196
  agent,
197
197
  headers: {
198
- 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36',
198
+ /**
199
+ * Always use a Windows UA. This is because Google fonts will including hinting in fonts for Windows.
200
+ * Hinting is a technique used with Windows files to improve appearance however
201
+ * results in 20-50% larger file sizes.
202
+ *
203
+ * @see http://google3/java/com/google/fonts/css/OpenSansWebFontsCssBuilder.java?l=22
204
+ * @see https://fonts.google.com/knowledge/glossary/hinting (short)
205
+ * @see https://glyphsapp.com/learn/hinting-manual-truetype-hinting (deep dive)
206
+ */
207
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
199
208
  },
200
209
  }, (res) => {
201
210
  if (res.statusCode !== 200) {
@@ -216,12 +225,16 @@ class InlineFontsProcessor {
216
225
  }
217
226
  return data;
218
227
  }
219
- async processHref(url) {
220
- const provider = this.getFontProviderDetails(url);
228
+ async processURL(url) {
229
+ const normalizedURL = url instanceof node_url_1.URL ? url : this.createNormalizedUrl(url);
230
+ if (!normalizedURL) {
231
+ return;
232
+ }
233
+ const provider = this.getFontProviderDetails(normalizedURL);
221
234
  if (!provider) {
222
235
  return undefined;
223
236
  }
224
- let cssContent = await this.getResponse(url);
237
+ let cssContent = await this.getResponse(normalizedURL);
225
238
  if (this.options.minify) {
226
239
  cssContent = cssContent
227
240
  // Comments.
@@ -233,21 +246,24 @@ class InlineFontsProcessor {
233
246
  }
234
247
  return cssContent;
235
248
  }
249
+ canInlineRequest(url) {
250
+ const normalizedUrl = this.createNormalizedUrl(url);
251
+ return normalizedUrl ? !!this.getFontProviderDetails(normalizedUrl) : false;
252
+ }
236
253
  getFontProviderDetails(url) {
237
254
  return SUPPORTED_PROVIDERS[url.hostname];
238
255
  }
239
256
  createNormalizedUrl(value) {
240
257
  // Need to convert '//' to 'https://' because the URL parser will fail with '//'.
241
- const normalizedHref = value.startsWith('//') ? `https:${value}` : value;
242
- if (!normalizedHref.startsWith('http')) {
243
- // Non valid URL.
244
- // Example: relative path styles.css.
245
- return undefined;
258
+ const url = new node_url_1.URL(value.startsWith('//') ? `https:${value}` : value, 'resolve://');
259
+ switch (url.protocol) {
260
+ case 'http:':
261
+ case 'https:':
262
+ url.protocol = 'https:';
263
+ return url;
264
+ default:
265
+ return undefined;
246
266
  }
247
- const url = new node_url_1.URL(normalizedHref);
248
- // Force HTTPS protocol
249
- url.protocol = 'https:';
250
- return url;
251
267
  }
252
268
  }
253
269
  exports.InlineFontsProcessor = InlineFontsProcessor;
@@ -8,6 +8,7 @@
8
8
  export * from './default-progress';
9
9
  export * from './delete-output-dir';
10
10
  export * from './run-module-as-observable-fork';
11
+ export * from './load-proxy-config';
11
12
  export * from './normalize-file-replacements';
12
13
  export * from './normalize-asset-patterns';
13
14
  export * from './normalize-source-maps';
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  __exportStar(require("./default-progress"), exports);
25
25
  __exportStar(require("./delete-output-dir"), exports);
26
26
  __exportStar(require("./run-module-as-observable-fork"), exports);
27
+ __exportStar(require("./load-proxy-config"), exports);
27
28
  __exportStar(require("./normalize-file-replacements"), exports);
28
29
  __exportStar(require("./normalize-asset-patterns"), exports);
29
30
  __exportStar(require("./normalize-source-maps"), exports);
@@ -37,8 +37,8 @@ const promises_1 = require("node:fs/promises");
37
37
  const node_path_1 = require("node:path");
38
38
  const node_url_1 = require("node:url");
39
39
  const picomatch_1 = require("picomatch");
40
- const error_1 = require("../../utils/error");
41
- const load_esm_1 = require("../../utils/load-esm");
40
+ const error_1 = require("./error");
41
+ const load_esm_1 = require("./load-esm");
42
42
  async function loadProxyConfiguration(root, proxyConfig, normalize = false) {
43
43
  if (!proxyConfig) {
44
44
  return undefined;
@@ -11,19 +11,20 @@ exports.getESMLoaderArgs = exports.callInitializeIfNeeded = void 0;
11
11
  const node_path_1 = require("node:path");
12
12
  const node_url_1 = require("node:url");
13
13
  const node_worker_threads_1 = require("node:worker_threads");
14
- let IS_NODE_18;
15
- function isNode18() {
16
- return (IS_NODE_18 ??= process.versions.node.startsWith('18.'));
14
+ const semver_1 = require("semver");
15
+ let SUPPORTS_IMPORT_FLAG;
16
+ function supportsImportFlag() {
17
+ return (SUPPORTS_IMPORT_FLAG ??= (0, semver_1.satisfies)(process.versions.node, '>= 18.19'));
17
18
  }
18
19
  /** Call the initialize hook when running on Node.js 18 */
19
20
  function callInitializeIfNeeded(initialize) {
20
- if (isNode18()) {
21
+ if (!supportsImportFlag()) {
21
22
  initialize(node_worker_threads_1.workerData);
22
23
  }
23
24
  }
24
25
  exports.callInitializeIfNeeded = callInitializeIfNeeded;
25
26
  function getESMLoaderArgs() {
26
- if (isNode18()) {
27
+ if (!supportsImportFlag()) {
27
28
  return [
28
29
  '--no-warnings', // Suppress `ExperimentalWarning: Custom ESM Loaders is an experimental feature...`.
29
30
  '--loader',
@@ -1,8 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- export declare function normalizePath(path: string): string;
@@ -1,22 +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.normalizePath = void 0;
11
- const node_os_1 = require("node:os");
12
- const node_path_1 = require("node:path");
13
- const USING_WINDOWS = (0, node_os_1.platform)() === 'win32';
14
- function normalizePath(path) {
15
- if (USING_WINDOWS) {
16
- return (0, node_path_1.normalize)(path).toLowerCase();
17
- }
18
- else {
19
- return (0, node_path_1.normalize)(path);
20
- }
21
- }
22
- exports.normalizePath = normalizePath;