Skip to content
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

[Feature Request] Angular: Support zoneless #28403

Open
3 tasks
valentinpalkovic opened this issue Jul 1, 2024 Discussed in #28400 · 7 comments · May be fixed by #28657
Open
3 tasks

[Feature Request] Angular: Support zoneless #28403

valentinpalkovic opened this issue Jul 1, 2024 Discussed in #28400 · 7 comments · May be fixed by #28657

Comments

@valentinpalkovic
Copy link
Contributor

valentinpalkovic commented Jul 1, 2024

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

@valentinpalkovic
Copy link
Contributor Author

Does someone want to work on it? I appreciate any help and can provide any guidance.

@anedomansky
Copy link

Hey, the task sounds really interesting and I would like to work on this!

@valentinpalkovic
Copy link
Contributor Author

Hi @anedomansky

Thank you for taking it! I will assign this task to you. Feel free to create a draft PR and link the issue also in a early state even if the work isn’t done completely. Let me know if you need any kind of support!

@anedomansky
Copy link

Hey @valentinpalkovic and thank you for assigning the task to me and offering your support 💪
I will start as soon as I am able to and update you about my progress or if I have any questions.

@valentinpalkovic
Copy link
Contributor Author

Hi @anedomansky

Do you have any remaining questions or issues getting started? Please let me know so that I can unblock you.

On the other side, if you don't have time to work on it, just let me know and I will unassign you. That is also totally fine! But then others might want to pick up the task.

@anedomansky
Copy link

Hey @valentinpalkovic ,

Thanks for reaching out!
I am actually planning to open my (draft) PR tomorrow!
Other than that, I have one open question:
Is there a preferred way to get the "polyfills"-value from the angular.json?
I looked through the repo and couldn't really find anything about that 🤔

@anedomansky anedomansky linked a pull request Jul 19, 2024 that will close this issue
8 tasks
@ed4becky
Copy link

Any update to this? I've looked at the commits but looks like they are not in main branch?

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

Successfully merging a pull request may close this issue.

4 participants