Skip to content

Build error in zoneless SSR with polyfill #34001

Description

@jackalvrus

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

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:

  1. Create a new Angular 22 SSR project:
ng new polyfill-error --ssr --style sass --ai-config none
  1. Edit the project and add a file named polyfills.ts in the root directory.

  2. 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"],
  1. Add polyfills.ts to files in tsconfig.app.json:
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": [
      "node"
    ]
  },
  "files": ["polyfills.ts"],
  1. Build the application:
npm run build

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions