@angular/build 19.0.0-next.1 → 19.0.0-next.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/build",
3
- "version": "19.0.0-next.1",
3
+ "version": "19.0.0-next.2",
4
4
  "description": "Official build system for Angular",
5
5
  "keywords": [
6
6
  "Angular CLI",
@@ -23,7 +23,7 @@
23
23
  "builders": "builders.json",
24
24
  "dependencies": {
25
25
  "@ampproject/remapping": "2.3.0",
26
- "@angular-devkit/architect": "0.1900.0-next.1",
26
+ "@angular-devkit/architect": "0.1900.0-next.2",
27
27
  "@babel/core": "7.25.2",
28
28
  "@babel/helper-annotate-as-pure": "7.24.7",
29
29
  "@babel/helper-split-export-declaration": "7.24.7",
@@ -42,7 +42,7 @@
42
42
  "parse5-html-rewriting-stream": "7.0.0",
43
43
  "picomatch": "4.0.2",
44
44
  "piscina": "4.6.1",
45
- "rollup": "4.21.0",
45
+ "rollup": "4.21.1",
46
46
  "sass": "1.77.8",
47
47
  "semver": "7.6.3",
48
48
  "vite": "5.4.2",
@@ -53,7 +53,7 @@
53
53
  "@angular/localize": "^19.0.0-next.0",
54
54
  "@angular/platform-server": "^19.0.0-next.0",
55
55
  "@angular/service-worker": "^19.0.0-next.0",
56
- "@angular/ssr": "^19.0.0-next.1",
56
+ "@angular/ssr": "^19.0.0-next.2",
57
57
  "less": "^4.2.0",
58
58
  "postcss": "^8.4.0",
59
59
  "tailwindcss": "^2.0.0 || ^3.0.0",
@@ -0,0 +1,19 @@
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.dev/license
7
+ */
8
+
9
+ // The `bundled_critters` causes issues with module mappings in Bazel,
10
+ // leading to unexpected behavior with esbuild. Specifically, the problem occurs
11
+ // when esbuild resolves to a different module or version than expected, due to
12
+ // how Bazel handles module mappings.
13
+ //
14
+ // This change aims to resolve esbuild types correctly and maintain consistency
15
+ // in the Bazel build process.
16
+
17
+ declare module 'esbuild' {
18
+ export * from 'esbuild-wasm';
19
+ }
@@ -22,38 +22,53 @@ const MEDIA_SET_HANDLER_PATTERN = /^this\.media=["'](.*)["'];?$/;
22
22
  */
23
23
  const CSP_MEDIA_ATTR = 'ngCspMedia';
24
24
  /**
25
- * Script text used to change the media value of the link tags.
25
+ * Script that dynamically updates the `media` attribute of `<link>` tags based on a custom attribute (`CSP_MEDIA_ATTR`).
26
26
  *
27
27
  * NOTE:
28
28
  * We do not use `document.querySelectorAll('link').forEach((s) => s.addEventListener('load', ...)`
29
- * because this does not always fire on Chome.
29
+ * because load events are not always triggered reliably on Chrome.
30
30
  * See: https://github.com/angular/angular-cli/issues/26932 and https://crbug.com/1521256
31
+ *
32
+ * The script:
33
+ * - Ensures the event target is a `<link>` tag with the `CSP_MEDIA_ATTR` attribute.
34
+ * - Updates the `media` attribute with the value of `CSP_MEDIA_ATTR` and then removes the attribute.
35
+ * - Removes the event listener when all relevant `<link>` tags have been processed.
36
+ * - Uses event capturing (the `true` parameter) since load events do not bubble up the DOM.
31
37
  */
32
- const LINK_LOAD_SCRIPT_CONTENT = [
33
- '(() => {',
34
- ` const CSP_MEDIA_ATTR = '${CSP_MEDIA_ATTR}';`,
35
- ' const documentElement = document.documentElement;',
36
- ' const listener = (e) => {',
37
- ' const target = e.target;',
38
- ` if (!target || target.tagName !== 'LINK' || !target.hasAttribute(CSP_MEDIA_ATTR)) {`,
39
- ' return;',
40
- ' }',
41
- ' target.media = target.getAttribute(CSP_MEDIA_ATTR);',
42
- ' target.removeAttribute(CSP_MEDIA_ATTR);',
43
- // Remove onload listener when there are no longer styles that need to be loaded.
44
- ' if (!document.head.querySelector(`link[${CSP_MEDIA_ATTR}]`)) {',
45
- ` documentElement.removeEventListener('load', listener);`,
46
- ' }',
47
- ' };',
48
- // We use an event with capturing (the true parameter) because load events don't bubble.
49
- ` documentElement.addEventListener('load', listener, true);`,
50
- '})();',
51
- ].join('\n');
52
- class CrittersExtended extends critters_1.default {
38
+ const LINK_LOAD_SCRIPT_CONTENT = `
39
+ (() => {
40
+ const CSP_MEDIA_ATTR = '${CSP_MEDIA_ATTR}';
41
+ const documentElement = document.documentElement;
42
+
43
+ // Listener for load events on link tags.
44
+ const listener = (e) => {
45
+ const target = e.target;
46
+ if (
47
+ !target ||
48
+ target.tagName !== 'LINK' ||
49
+ !target.hasAttribute(CSP_MEDIA_ATTR)
50
+ ) {
51
+ return;
52
+ }
53
+
54
+ target.media = target.getAttribute(CSP_MEDIA_ATTR);
55
+ target.removeAttribute(CSP_MEDIA_ATTR);
56
+
57
+ if (!document.head.querySelector(\`link[\${CSP_MEDIA_ATTR}]\`)) {
58
+ documentElement.removeEventListener('load', listener);
59
+ }
60
+ };
61
+
62
+ documentElement.addEventListener('load', listener, true);
63
+ })();
64
+ `.trim();
65
+ class CrittersBase extends critters_1.default {
66
+ }
67
+ /* eslint-enable @typescript-eslint/no-unsafe-declaration-merging */
68
+ class CrittersExtended extends CrittersBase {
53
69
  optionsExtended;
54
70
  warnings = [];
55
71
  errors = [];
56
- initialEmbedLinkedStylesheet;
57
72
  addedCspScriptsDocuments = new WeakSet();
58
73
  documentNonces = new WeakMap();
59
74
  constructor(optionsExtended) {
@@ -71,17 +86,12 @@ class CrittersExtended extends critters_1.default {
71
86
  reduceInlineStyles: false,
72
87
  mergeStylesheets: false,
73
88
  // Note: if `preload` changes to anything other than `media`, the logic in
74
- // `embedLinkedStylesheetOverride` will have to be updated.
89
+ // `embedLinkedStylesheet` will have to be updated.
75
90
  preload: 'media',
76
91
  noscriptFallback: true,
77
92
  inlineFonts: true,
78
93
  });
79
94
  this.optionsExtended = optionsExtended;
80
- // We can't use inheritance to override `embedLinkedStylesheet`, because it's not declared in
81
- // the `Critters` .d.ts which means that we can't call the `super` implementation. TS doesn't
82
- // allow for `super` to be cast to a different type.
83
- this.initialEmbedLinkedStylesheet = this.embedLinkedStylesheet;
84
- this.embedLinkedStylesheet = this.embedLinkedStylesheetOverride;
85
95
  }
86
96
  readFile(path) {
87
97
  const readAsset = this.optionsExtended.readAsset;
@@ -91,7 +101,7 @@ class CrittersExtended extends critters_1.default {
91
101
  * Override of the Critters `embedLinkedStylesheet` method
92
102
  * that makes it work with Angular's CSP APIs.
93
103
  */
94
- embedLinkedStylesheetOverride = async (link, document) => {
104
+ async embedLinkedStylesheet(link, document) {
95
105
  if (link.getAttribute('media') === 'print' && link.next?.name === 'noscript') {
96
106
  // Workaround for https://github.com/GoogleChromeLabs/critters/issues/64
97
107
  // NB: this is only needed for the webpack based builders.
@@ -102,7 +112,7 @@ class CrittersExtended extends critters_1.default {
102
112
  link?.next?.remove();
103
113
  }
104
114
  }
105
- const returnValue = await this.initialEmbedLinkedStylesheet(link, document);
115
+ const returnValue = await super.embedLinkedStylesheet(link, document);
106
116
  const cspNonce = this.findCspNonce(document);
107
117
  if (cspNonce) {
108
118
  const crittersMedia = link.getAttribute('onload')?.match(MEDIA_SET_HANDLER_PATTERN);
@@ -126,7 +136,7 @@ class CrittersExtended extends critters_1.default {
126
136
  });
127
137
  }
128
138
  return returnValue;
129
- };
139
+ }
130
140
  /**
131
141
  * Finds the CSP nonce for a specific document.
132
142
  */
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeCacheOptions = normalizeCacheOptions;
11
11
  const node_path_1 = require("node:path");
12
12
  /** Version placeholder is replaced during the build process with actual package version */
13
- const VERSION = '19.0.0-next.1';
13
+ const VERSION = '19.0.0-next.2';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&