Skip to content

[Feature Request] Angular: Support zoneless #28403

Open

Description

Discussed in #28400

Originally posted by valentinpalkovic July 1, 2024

Is your feature request related to a problem? Please describe.

Currently, Storybook always uses zone.js for change detection.

Describe the solution you'd like

Angular has introduced an experimental feature called zoneless.
The main benefit is that users can remove Zone.js to

  • Improved performance
  • Improved Core Web Vitals
  • Improved debugging experience
  • Better ecosystem compatibility

The solution would be to enable experimental zoneless mode in Storybook by setting an experimental flag in Storybook's Angular builder options

// angular.json
{
  "storybook": {
      "builder": "@storybook/angular:start-storybook",
      "options": {
         ...
         "experimentalZoneless": true
       }
   },
   "build-storybook": {
      "builder": "@storybook/angular:build-storybook",
      "options": {
            ...
            "experimentalZoneless": true
       }
    }
}

Tasklist

const applicationRef = await queueBootstrapping(() => {
      return bootstrapApplication(application, {
        ...storyFnAngular.applicationConfig,
        providers: [
+        // Consider, that `provideExperimentalZonelessChangeDetection` cannot be imported "normally", because former Angular versions do not provide this export. A conditional dynamic import will be necessary
+        experimentalZoneless ? provideExperimentalZonelessChangeDetection() : null          
          storyPropsProvider(newStoryProps$),
          ...analyzedMetadata.applicationProviders,
          ...(storyFnAngular.applicationConfig?.providers ?? []),
-        ],
+        ].filter(Boolean),
      });
    });

Acceptance criteria

  • If a user does not have zone.js in angular.json's <project>/architect/build/polyfills array defined AND the experimentalZoneless option is set in <project>/architect/storybook|build-storybook/options, Storybook and change detection via control changes should work.

Development workflow

Describe alternatives you've considered

No response

Are you able to assist to bring the feature to reality?

As a maintainer I can support contributors to implement this feature if questions arise.

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions