Skip to content

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Sep 30, 2025

Closes #

What I did

Starting in Angular 21, zone.js is not included anymore. Therefore, we set the experimentalZoneless option turned on by default.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • New Features
    • Automatically enables zoneless mode when running with Angular v21+; remains configurable via experimentalZoneless.
  • Bug Fixes
    • Ensures the experimentalZoneless setting is correctly propagated to the final build/start options.
  • Documentation
    • Updated Angular docs and links; added experimentalZoneless option entry and clarified sourceMap reference.
  • Chores
    • Reformatted Angular schemas for readability; removed the schema default for experimentalZoneless (no other behavioral changes).

@yannbf yannbf self-assigned this Sep 30, 2025
@yannbf yannbf added angular patch:yes Bugfix & documentation PR that need to be picked to main branch ci:daily Run the CI jobs that normally run in the daily job. labels Sep 30, 2025
Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

  • Removed the default value for experimentalZoneless from Angular build/start JSON schemas; descriptions unchanged and other schema formatting reflowed without semantic changes.
  • In build-storybook and start-storybook builders, imported VERSION from @angular/core and changed the default for experimentalZoneless to true when Angular VERSION.major >= 21, otherwise false.
  • Updated option destructuring in both builders to use this version-based default and to pass the resulting value into StandaloneOptions.
  • In the Angular CLI framework preset, propagated angularBuilderOptions.experimentalZoneless into the final builderOptions.
  • Documentation updated: sourceMap link now points to angular.dev and experimentalZoneless documented. No public API or signature changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant CLI as Storybook CLI (start/build)
  participant Builder as Angular Storybook Builder
  participant NG as @angular/core (VERSION)
  participant Preset as framework-preset-angular-cli
  participant Exec as Angular Builder Execution

  User->>CLI: Run start-storybook / build-storybook
  CLI->>Builder: Initialize with options
  Builder->>NG: Read VERSION.major
  alt VERSION.major >= 21
    note right of Builder: experimentalZoneless -> true
  else VERSION.major missing or < 21
    note right of Builder: experimentalZoneless -> false
  end
  Builder->>Preset: getBuilderOptions(options with experimentalZoneless)
  Preset->>Preset: builderOptions.experimentalZoneless = options.angularBuilderOptions?.experimentalZoneless
  Preset-->>Builder: Return builderOptions
  Builder->>Exec: Invoke Angular build/start with builderOptions
  Exec-->>User: Build/Serve result
Loading

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the core change by indicating that experimental zoneless detection will be enabled for Angular version 21, which aligns precisely with the modifications in the code and documentation. It is specific to the main objective—adjusting the default behavior for Angular v21—without unnecessary detail or generic phrasing, making it clear to reviewers scanning the history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch yann/enable-zoneless-on-angular-21

Comment @coderabbitai help to get the list of available commands and usage tips.

@ndelangen ndelangen self-requested a review September 30, 2025 08:39
Copy link

nx-cloud bot commented Sep 30, 2025

View your CI Pipeline Execution ↗ for commit bef0400

Command Status Duration Result
nx run-many -t check -c production --parallel=7 ✅ Succeeded 1s View ↗
nx run-many -t build -c production --parallel=3 ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-30 10:06:31 UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 79b35ae and c1002cb.

📒 Files selected for processing (5)
  • code/frameworks/angular/build-schema.json (5 hunks)
  • code/frameworks/angular/src/builders/build-storybook/index.ts (2 hunks)
  • code/frameworks/angular/src/builders/start-storybook/index.ts (2 hunks)
  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts (1 hunks)
  • code/frameworks/angular/start-schema.json (6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Adhere to ESLint and Prettier rules across all JS/TS source files

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
  • code/frameworks/angular/src/builders/build-storybook/index.ts
  • code/frameworks/angular/src/builders/start-storybook/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
  • code/frameworks/angular/src/builders/build-storybook/index.ts
  • code/frameworks/angular/src/builders/start-storybook/index.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Danger JS
  • GitHub Check: daily
  • GitHub Check: Core Unit Tests, windows-latest
  • GitHub Check: get-parameters

Comment on lines +153 to +154
builderOptions.experimentalZoneless = options.angularBuilderOptions?.experimentalZoneless;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Prevent clobbering target defaults for experimentalZoneless.

We deep-merge the target options first, which already capture experimentalZoneless from the Angular browser target. The new unconditional assignment overwrites that with undefined whenever Storybook didn’t explicitly pass the option (common when the preset runs outside our builders), so Angular’s v21-default of true regresses back to falsy. Please only assign when the Storybook options actually provide a boolean.

-  builderOptions.experimentalZoneless = options.angularBuilderOptions?.experimentalZoneless;
+  if (options.angularBuilderOptions?.experimentalZoneless !== undefined) {
+    builderOptions.experimentalZoneless = options.angularBuilderOptions.experimentalZoneless;
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
builderOptions.experimentalZoneless = options.angularBuilderOptions?.experimentalZoneless;
if (options.angularBuilderOptions?.experimentalZoneless !== undefined) {
builderOptions.experimentalZoneless = options.angularBuilderOptions.experimentalZoneless;
}
🤖 Prompt for AI Agents
In code/frameworks/angular/src/server/framework-preset-angular-cli.ts around
lines 153-154, the unconditional assignment "builderOptions.experimentalZoneless
= options.angularBuilderOptions?.experimentalZoneless" clobbers defaults when
Storybook doesn't supply the option; change it to only set
builderOptions.experimentalZoneless when
options.angularBuilderOptions?.experimentalZoneless is a boolean (e.g., guard
with typeof === 'boolean' before assigning) so existing merged target defaults
are preserved otherwise.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/get-started/frameworks/angular.mdx (1)

17-18: Fix Angular version range in requirements

This PR enables Storybook to work with Angular 21 when zoneless detection is on, but the requirements still read “Angular ≥ 18.0 < 21.0”. That excludes 21 entirely and will mislead anyone trying to follow the docs for the newly supported version. Please update the stated range (e.g., “Angular ≥ 18.0 ≤ 21.x” or similar) so it reflects the new compatibility.

🧹 Nitpick comments (1)
docs/get-started/frameworks/angular.mdx (1)

370-372: Document the new default behavior for experimentalZoneless

With Angular ≥ 21 the builders now enable zoneless by default, while older majors leave it off. Call that out here so readers know when they actually need to set the option manually.

-| `"experimentalZoneless"`     | Configure [zoneless change detection](https://angular.dev/guide/zoneless). <br /> `"experimentalZoneless": true`                                                                 |
+| `"experimentalZoneless"`     | Configure [zoneless change detection](https://angular.dev/guide/zoneless). Defaults to `true` on Angular 21+ and `false` otherwise. <br /> `"experimentalZoneless": true` |
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1002cb and bef0400.

📒 Files selected for processing (1)
  • docs/get-started/frameworks/angular.mdx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: daily
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (1)
docs/get-started/frameworks/angular.mdx (1)

375-376: Schema link updates look good

The links now point at the live JSON schemas under code/frameworks/angular/…; no further action needed.

@yannbf yannbf added the bug label Sep 30, 2025
@yannbf yannbf merged commit 55d57b9 into next Sep 30, 2025
93 of 99 checks passed
@yannbf yannbf deleted the yann/enable-zoneless-on-angular-21 branch September 30, 2025 10:03
ndelangen pushed a commit that referenced this pull request Sep 30, 2025
…gular-21

Angular: Enable experimental zoneless detection on Angular v21
(cherry picked from commit 55d57b9)
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular bug ci:daily Run the CI jobs that normally run in the daily job. patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants