Skip to content

[Bug] Storybook experimentalZoneless is not compatible with Angular 20 #31652

Closed
@DanielBertocci

Description

@DanielBertocci

Describe the bug

With Angular 20, it was dropped provideExperimentalZonelessChangeDetection() (now, not found), in favor of provideZonelessChangeDetection().

Because of this change, the work provided at #28657 became incompatible for new versions of Angular. In particular, here it is needed a bit more logic if you want to support both Angular 19 and Angular >20.

Reproduction link

https://stackblitz.com/edit/github-ztfqrp12?file=src%2Fapp%2Fapp.config.ts,angular.json

Reproduction steps

  1. Use https://new-storybook.netlify.app/ and Select Angular Cli
  2. Change provideZoneChangeDetection into provideZonelessChangeDetection
  3. Delete zone.js from polyfills in angular.json and as dependency in package.json

This causes a compilation error:

Run Storybook with --debug-webpack for more information.
    at new StorybookError (./node_modules/storybook/dist/server-errors.cjs:180:5)
    at new WebpackCompilationError (./node_modules/storybook/dist/server-errors.cjs:367:5)
    at starter (./node_modules/@storybook/builder-webpack5/dist/index.js:1:24378)
    at Module.start (./node_modules/@storybook/builder-webpack5/dist/index.js:1:26340)
    at async storybookDevServer (./node_modules/storybook/dist/core-server/index.cjs:36757:79)
    at async buildOrThrow (./node_modules/storybook/dist/core-server/index.cjs:35372:12)
    at async buildDevStandalone (./node_modules/storybook/dist/core-server/index.cjs:37985:78)
    at async withTelemetry (./node_modules/storybook/dist/core-server/index.cjs:36122:12)
  1. Try to fix it using "experimentalZoneless": true in angular.json
  2. It compiles and Storybook runs, but with the following error:
Error: Experimental zoneless change detection requires Angular 18 or higher
  at Generator.next (<anonymous>))
  at asyncGeneratorStep (/vendors-node_modules_storybook_addon-docs_angular_index_js-node_modules_storybook_addon-docs_-1e03ce.iframe.bundle.js:83754:17))
  at _next (/vendors-node_modules_storybook_addon-docs_angular_index_js-node_modules_storybook_addon-docs_-1e03ce.iframe.bundle.js:83768:9))

System

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm <----- active
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @storybook/addon-docs: ^9.1.0-alpha.2 => 9.1.0-alpha.2 
    @storybook/addon-onboarding: ^9.1.0-alpha.2 => 9.1.0-alpha.2 
    @storybook/angular: ^9.1.0-alpha.2 => 9.1.0-alpha.2 
    storybook: ^9.1.0-alpha.2 => 9.1.0-alpha.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions