Skip to content

Zoneless breaks when polyfill is used #30239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
xionglingfeng opened this issue May 3, 2025 · 0 comments
Closed
1 task

Zoneless breaks when polyfill is used #30239

xionglingfeng opened this issue May 3, 2025 · 0 comments

Comments

@xionglingfeng
Copy link

Command

serve

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

We have an legacy Angular application with i18n enabled. We migrated this application to v19, then enabled Zoneless by removing zone.js and adding provideExperimentalZonelessChangeDetection() in providers: []. We also enabled SSR.

However, the program failed to run

> ng serve

Component HMR has been enabled.
If you encounter application reload issues, you can manually reload the page to bypass HMR and/or disable this feature with the `--no-hmr` command line option.
Please consider reporting any issues you encounter here: https://github.com/angular/angular-cli/issues

Application bundle generation failed. [11.083 seconds]

✘ [ERROR] Could not resolve "zone.js/node"

    angular:polyfills-server:angular:polyfills-server:2:7:
      2 │ import 'zone.js/node';
        ╵        ~~~~~~~~~~~~~~

  You can mark the path "zone.js/node" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.


Watch mode enabled. Watching for file changes...

Searching shows a similar unresolved bug here.
By removing all items in architect:build:polyfills in angular.json (i.e., set it to be an empty array), the issue is gone.
Originally, that array includes two items:

            "polyfills": [
              "src/polyfills.ts",
              "@angular/localize/init"
            ],

Minimal Reproduction

  1. npx ng add @angular/ssr --server-routing
  2. npx pnpm uninstall zone.js
  3. add provideExperimentalZonelessChangeDetection() in providers: []
  4. npx pnpm start

Exception or Error

> ng serve

Component HMR has been enabled.
If you encounter application reload issues, you can manually reload the page to bypass HMR and/or disable this feature with the `--no-hmr` command line option.
Please consider reporting any issues you encounter here: https://github.com/angular/angular-cli/issues

Application bundle generation failed. [12.035 seconds]

✘ [ERROR] Could not resolve "zone.js/node"

    angular:polyfills-server:angular:polyfills-server:2:7:
      2 │ import 'zone.js/node';
        ╵        ~~~~~~~~~~~~~~

  You can mark the path "zone.js/node" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.


Watch mode enabled. Watching for file changes...

Your Environment

Angular CLI: 19.2.9
Node: 22.15.0
Package Manager: pnpm 10.10.0
OS: win32 x64

Angular: 19.2.8
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.9
@angular-devkit/build-angular   19.2.9
@angular-devkit/core            19.2.9
@angular-devkit/schematics      19.2.9
@angular/cli                    19.2.9
@angular/platform-server        19.2.9
@angular/ssr                    19.2.10
@schematics/angular             19.2.9
rxjs                            7.8.2
typescript                      5.8.3

Anything else relevant?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants