#36453·storybook

[Bug]: @storybook/angular-vite accepts @analogjs/vite-plugin-angular versions that break build-storybook on Angular 22.2

Author: pvdsCreated Sep 25, 2026Updated Sep 28, 2026
Labelsbugneeds triage

Describe the bug

@storybook/angular-vite declares its Analog peer as:

json
"@analogjs/vite-plugin-angular": ">=2.0.0"

That range allows @analogjs/[email protected]. On @angular/[email protected], 2.7.2 crashes build-storybook while transforming Angular FESM bundles:

■  Build failed with 32 errors:
│  [plugin @analogjs/vite-plugin-angular-optimizer]
│  node_modules/@angular/core/fesm2022/core.mjs
│  AssertionError [ERR_ASSERTION]: Hash utility must be initialized by awaiting `initializeHash()` before use.
│  at getXxhash (@angular/build/src/utils/hash.js:63:31)
│  at createContentHash (@angular/build/src/utils/hash.js:81:22)
│  at #transform (@angular/build/src/tools/javascript-transformer/javascript-transformer.js:230:57)
│  at async TransformPluginContextImpl.handler (@analogjs/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.js:82:32)
│  ...
■  Failed to build the preview
Error: Broken build, fix the error above.
    at runInstance (@storybook/angular-vite/dist/builders/build-storybook/index.js:120:11)

Angular 22.2 changed the private JavaScriptTransformer API that Analog uses. Analog fixed this in 2.7.3 (analogjs/analog#2576), and 2.7.3 still supports Angular 21.

Many projects stay on 2.7.2 without noticing:

  • pnpm and Yarn auto-install the peer, then keep whatever version the lockfile first recorded.
  • storybook init and the angular-to-angular-vite automigration write ANALOG_VITE_PLUGIN_ANGULAR_VERSION = '^2.5.2', which also allows the locked 2.7.2.

In both cases pnpm install and pnpm peers check pass, so the problem only shows up at build time after upgrading Angular to 22.2.

Expected: @storybook/angular-vite requires an Analog version that works across its supported Angular range (>=21.0.0 <23.0.0). A stale Analog version should then fail at install time with a peer error, instead of crashing build-storybook.

Suggested fix:

  • code/frameworks/angular-vite/package.json: change the peer "@analogjs/vite-plugin-angular" from ">=2.0.0" to ">=2.7.3".
  • code/core/src/cli/angular/helpers.ts: change ANALOG_VITE_PLUGIN_ANGULAR_VERSION from '^2.5.2' to '^2.7.3'.

Reproduction link

https://github.com/pvds/storybook-analog-angular-22-2-repro

Reproduction steps

The reproduction is a fresh Angular 22.2 CLI app with @storybook/[email protected] and one story. @analogjs/vite-plugin-angular is pinned to 2.7.2, which matches a lockfile that resolved the peer before 2.7.3 was released.

  1. Clone the reproduction repository and run pnpm install.
  2. Run pnpm peers check. It passes, because 2.7.2 satisfies >=2.0.0.
  3. Run pnpm build-storybook.
  4. The build fails with AssertionError: Hash utility must be initialized by awaiting initializeHash() before use.
  5. Run pnpm add -D @analogjs/[email protected], then pnpm build-storybook again. The build now succeeds.

System

bash
Storybook Environment Info:

  System:
    OS: macOS 26.6.2
    CPU: (10) arm64 Apple M1 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.20.0
    pnpm: 11.25.0
  Browsers:
    Chrome: 153.0.8010.53
    Edge: 151.0.4129.101
    Firefox: 146.0.1
    Safari: 27.0
  npmPackages:
    @storybook/addon-a11y: 10.6.0
    @storybook/addon-docs: 10.6.0
    @storybook/addon-themes: 10.6.0
    @storybook/angular-vite: 10.6.0
    @storybook/test-runner: 0.24.5
    eslint-plugin-storybook: 10.6.0
    msw-storybook-addon: 3.0.3
    storybook: 10.6.0

Additional context

Also relevant: @angular/build 22.2.0, @analogjs/vite-plugin-angular 2.7.2 (failing) and 2.7.5 (working), vite 8.3.0, nx 23.2.1.

  • The same failure was reported in #36366 against Angular 22.2.0-rc.0. The bot closed it because it had no reproduction link, so it was never triaged.
  • Analog issue analogjs/analog#2574 describes the root cause: @angular/build 22.2 changed the JavaScriptTransformer constructor and requires initializeHash().
  • Analog fix analogjs/analog#2576 shipped in @analogjs/[email protected].
  • #36002 already notes that ANALOG_VITE_PLUGIN_ANGULAR_VERSION is an unbounded ^2.5.2.
  • Workaround: declare @analogjs/vite-plugin-angular@^2.7.3 explicitly as a devDependency.