Command
build
Is this a regression?
The previous version in which this bug was not present was
No response
Description
After adding a polyfill to a SSR project, the following error is reported:
✘ [ERROR] Could not resolve "zone.js/node"
angular:polyfills-server:angular:polyfills-server:1:7:
1 │ import 'zone.js/node';
╵ ~~~~~~~~~~~~~~
I tracked it down to having any polyfill with an extension that matches the regex: /\.[mc]?[jt]s$/. So .js and .ts files are affected.
Minimal Reproduction
Repro repository: https://github.com/jackalvrus/angular-polyfill-error
To manually reproduce this error, do the following:
- Create a new Angular 22 SSR project:
ng new polyfill-error --ssr --style sass --ai-config none
-
Edit the project and add a file named polyfills.ts in the root directory.
-
Edit the angular.json file and add a reference to polyfills.ts in the build options:
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"polyfills":["polyfills.ts"],
- Add
polyfills.ts to files in tsconfig.app.json:
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": [
"node"
]
},
"files": ["polyfills.ts"],
- Build the application:
Note that an error is reported.
Exception or Error
✘ [ERROR] Could not resolve "zone.js/node"
angular:polyfills-server:angular:polyfills-server:1:7:
1 │ import 'zone.js/node';
╵ ~~~~~~~~~~~~~~
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI : 22.1.6
Angular : 22.1.4
Node.js : 26.0.0
Package Manager : npm 11.12.1
Operating System : win32 x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 22.1.6 │ ^22.0.2 │
│ @angular/cli │ 22.1.6 │ ^22.0.2 │
│ @angular/common │ 22.1.4 │ ^22.0.0 │
│ @angular/compiler │ 22.1.4 │ ^22.0.0 │
│ @angular/compiler-cli │ 22.1.4 │ ^22.0.0 │
│ @angular/core │ 22.1.4 │ ^22.0.0 │
│ @angular/forms │ 22.1.4 │ ^22.0.0 │
│ @angular/platform-browser │ 22.1.4 │ ^22.0.0 │
│ @angular/platform-server │ 22.1.4 │ ^22.0.0 │
│ @angular/router │ 22.1.4 │ ^22.0.0 │
│ @angular/ssr │ 22.1.6 │ ^22.0.2 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 6.0.3 │ ~6.0.2 │
│ vitest │ 4.1.11 │ ^4.0.8 │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response
Command
build
Is this a regression?
The previous version in which this bug was not present was
No response
Description
After adding a polyfill to a SSR project, the following error is reported:
I tracked it down to having any polyfill with an extension that matches the regex:
/\.[mc]?[jt]s$/. So .js and .ts files are affected.Minimal Reproduction
Repro repository: https://github.com/jackalvrus/angular-polyfill-error
To manually reproduce this error, do the following:
Edit the project and add a file named
polyfills.tsin the root directory.Edit the
angular.jsonfile and add a reference topolyfills.tsin the build options:polyfills.tstofilesintsconfig.app.json:Note that an error is reported.
Exception or Error
Your Environment
Anything else relevant?
No response