Command
serve
Is this a regression?
The previous version in which this bug was not present was
No response
Description
I would like to request a backport of #33525 to the Angular 21 branch.
The issue affects ng serve --configuration=production when externalDependencies are used and the generated code is optimized/minified. The angular-plugin-remove-id-prefix Vite plugin currently uses a greedy regex:
(?:/.+)?
When the generated code is minified into a single line and an external dependency has a deep import path (for example @angular/common/http), the regex can consume the remainder of the line. As a result, subsequent /@id/ prefixes are not stripped.
The browser then requests URLs such as:
/@id/@angular/router
The Angular dev server responds with the application's index.html fallback, resulting in:
Error: Unsupported Content-Type "text/html" loading http://localhost:4200/@id/@angular/core
The issue has already been fixed upstream changing the regular expression in:
#33525
Importantly, the PR explicitly states that the fix was verified end-to-end with @angular/build 21.2.0 by applying the change directly to node_modules in a real application.
Minimal Reproduction
A complete minimal reproduction is already available in the original issue:
Exception or Error
Error: Unsupported Content-Type "text/html" loading http://localhost:4200/@id/@angular/core
Your Environment
Angular CLI : 21.2.24
Angular : 21.2.23
Node.js : 24.16.0
Package Manager : npm 11.13.0
Operating System : win32 x64
┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 21.2.24 │ ~21.2.11 │
│ @angular/cdk │ 21.2.14 │ ~21.2.11 │
│ @angular/cli │ 21.2.24 │ ~21.2.11 │
│ @angular/common │ 21.2.23 │ ~21.2.11 │
│ @angular/compiler │ 21.2.23 │ ~21.2.11 │
│ @angular/compiler-cli │ 21.2.23 │ ~21.2.11 │
│ @angular/core │ 21.2.23 │ ~21.2.11 │
│ @angular/forms │ 21.2.23 │ ~21.2.11 │
│ @angular/platform-browser │ 21.2.23 │ ~21.2.11 │
│ @angular/router │ 21.2.23 │ ~21.2.11 │
│ ng-packagr │ 21.2.7 │ ^21.0.0 │
│ rxjs │ 7.8.2 │ ~7.8.2 │
│ typescript │ 5.9.3 │ ~5.9.0 │
│ zone.js │ 0.16.3 │ ~0.16.2 │
└───────────────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response
Command
serve
Is this a regression?
The previous version in which this bug was not present was
No response
Description
I would like to request a backport of #33525 to the Angular 21 branch.
The issue affects
ng serve --configuration=productionwhenexternalDependenciesare used and the generated code is optimized/minified. Theangular-plugin-remove-id-prefixVite plugin currently uses a greedy regex:(?:/.+)?
When the generated code is minified into a single line and an external dependency has a deep import path (for example
@angular/common/http), the regex can consume the remainder of the line. As a result, subsequent /@id/ prefixes are not stripped.The browser then requests URLs such as:
/@id/@angular/router
The Angular dev server responds with the application's
index.htmlfallback, resulting in:Error: Unsupported Content-Type "text/html" loading http://localhost:4200/@id/@angular/core
The issue has already been fixed upstream changing the regular expression in:
#33525
Importantly, the PR explicitly states that the fix was verified end-to-end with
@angular/build21.2.0 by applying the change directly to node_modules in a real application.Minimal Reproduction
A complete minimal reproduction is already available in the original issue:
Issue dev-server: /@id/ prefix not stripped from minified bundles when using externalDependencies (greedy regex in createRemoveIdPrefixPlugin) #33524:
Fix: PR #33525
Exception or Error
Your Environment
Anything else relevant?
No response