From c6ce93eb0d21632046bebe9ee2c7df9147e164db Mon Sep 17 00:00:00 2001
From: Alan Agius <17563226+alan-agius4@users.noreply.github.com>
Date: Thu, 23 Jul 2026 08:09:53 +0000
Subject: [PATCH 1/2] test: allow hyphens in hash for server routes preload
links
Updates the regular expressions in server-routes-preload-links.ts to allow hyphens in the generated file hashes (changing [a-zA-Z0-9_]{8} to [a-zA-Z0-9_-]{8}).
This ensures that the test correctly identifies modulepreload links when the hash contains a hyphen, preventing failures due to overly strict matching.
---
.../server-routes-preload-links.ts | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tests/e2e/tests/build/server-rendering/server-routes-preload-links.ts b/tests/e2e/tests/build/server-rendering/server-routes-preload-links.ts
index 5eeef8888860..697f2234fbf7 100644
--- a/tests/e2e/tests/build/server-rendering/server-routes-preload-links.ts
+++ b/tests/e2e/tests/build/server-rendering/server-routes-preload-links.ts
@@ -137,36 +137,36 @@ const RESPONSE_EXPECTS: Record<
}
> = {
'/': {
- matches: [//],
+ matches: [//],
notMatches: [/ssg\-component/, /ssr/, /csr/, /cross-dep-/],
},
'/ssg': {
matches: [
- //,
- //,
+ //,
+ //,
],
notMatches: [/home/, /ssr/, /csr/, /ssg-one/, /ssg-two/, /cross-dep-/],
},
'/ssg/one': {
matches: [
- //,
- //,
+ //,
+ //,
],
notMatches: [/home/, /ssr/, /csr/, /ssg-two/, /ssg\-component/, /cross-dep-/],
},
'/ssg/two': {
matches: [
- //,
- //,
+ //,
+ //,
],
notMatches: [/home/, /ssr/, /csr/, /ssg-one/, /ssg\-component/, /cross-dep-/],
},
'/ssr': {
- matches: [//],
+ matches: [//],
notMatches: [/home/, /ssg\-component/, /csr/],
},
'/csr': {
- matches: [//],
+ matches: [//],
notMatches: [/home/, /ssg\-component/, /ssr/, /cross-dep-/],
},
};
From e0dcf4e0f93ee1f66f73a39b2427e158c9093bef Mon Sep 17 00:00:00 2001
From: Alan Agius <17563226+alan-agius4@users.noreply.github.com>
Date: Thu, 23 Jul 2026 08:13:57 +0000
Subject: [PATCH 2/2] fix(@angular/build): support hyphens and underscores when
stripping chunk hash in chunk optimizer
Updates the regular expression in chunkFileNames from /-[a-zA-Z0-9]{8}$/ to /-[a-zA-Z0-9_-]{8}$/ to properly strip esbuild intermediate chunk hashes containing hyphens or underscores before applying Rolldown/Rollup chunk hashes.
---
.../angular/build/src/builders/application/chunk-optimizer.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/angular/build/src/builders/application/chunk-optimizer.ts b/packages/angular/build/src/builders/application/chunk-optimizer.ts
index 61ec816d46ba..7d7a6e56b829 100644
--- a/packages/angular/build/src/builders/application/chunk-optimizer.ts
+++ b/packages/angular/build/src/builders/application/chunk-optimizer.ts
@@ -302,7 +302,7 @@ export async function optimizeChunks(
minify: { mangle: false, compress: false },
sourcemap,
chunkFileNames: (chunkInfo) =>
- `${chunkInfo.name.replace(/-[a-zA-Z0-9]{8}$/, '')}-[hash].js`,
+ `${chunkInfo.name.replace(/-[a-zA-Z0-9_-]{8}$/, '')}-[hash].js`,
});
optimizedOutput = result.output;
} else {
@@ -324,7 +324,7 @@ export async function optimizeChunks(
compact: true,
sourcemap,
chunkFileNames: (chunkInfo) =>
- `${chunkInfo.name.replace(/-[a-zA-Z0-9]{8}$/, '')}-[hash].js`,
+ `${chunkInfo.name.replace(/-[a-zA-Z0-9_-]{8}$/, '')}-[hash].js`,
});
optimizedOutput = result.output;
}