Skip to content

Addon Vitest: Pin storybook/test in optimizeDeps so its CJS-only deps are prebundled - #35572

Merged
valentinpalkovic merged 1 commit into
storybookjs:nextfrom
Nic-Polumeyv:fix/addon-vitest-optimize-storybook-test
Jul 24, 2026
Merged

valentinpalkovic merged 1 commit into
storybookjs:nextfrom
Nic-Polumeyv:fix/addon-vitest-optimize-storybook-test

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What I did

In Vitest browser mode, whether storybook/test's CJS-only deps (aria-query, lz-string, pretty-format, all via @testing-library/dom) get prebundled depends on the project's node_modules layout. On npm's hoisted layout, in a project whose stories don't import storybook/test directly, every story test fails at import:

Caused by: SyntaxError: The requested module '/node_modules/aria-query/lib/index.js?v=...' does not provide an export named 'elementRoles'

pnpm's isolated layout works because the scanner happens to discover storybook/test there: it shows up in the dep-optimizer metadata, on hoisted it doesn't. Pinning it makes all layouts behave like the working one. Diagnosed in vitejs/vite#23030; reproduces identically on Vite 7.3.6 and 8.1.5, so it's an addon-side gap, not a Vite 8 regression. Vitest pins the same package for its own preview provider.

Checklist for Contributors

Testing

Manual testing

On https://github.com/OpenSourceScouting/design-system branch repro/vite8-rolldown-cjs-interop (Storybook 10.5.2, Vitest 4.1.10, Vite 8.1.5, hoisted node_modules), vitest run --project storybook fails all 36 story files with the error above; with 'storybook/test' in the published addon's include list, all 36 files (95 tests) pass. A pnpm isolated install passes before and after.

@Nic-Polumeyv
Nic-Polumeyv requested a review from a team July 24, 2026 06:42
@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor
Fails
🚫

PR is not labeled with one of: ["qa:needed","qa:skip","qa:success"]

Generated by 🚫 dangerJS against 5eb34c4

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ac4f099-0b11-4a15-8605-a54441dd3af8

📥 Commits

Reviewing files that changed from the base of the PR and between f6ac9d3 and 5eb34c4.

📒 Files selected for processing (1)
  • code/addons/vitest/src/vitest-plugin/index.ts

📝 Walkthrough

Walkthrough

The Vitest plugin’s Vite configuration explicitly includes storybook/test in dependency optimization and documents the node_modules resolution scenario this addresses.

Changes

Vitest dependency optimization

Layer / File(s) Summary
Pin storybook/test in optimized dependencies
code/addons/vitest/src/vitest-plugin/index.ts
Adds storybook/test to optimizeDeps.include with comments explaining its runtime dependency-resolution purpose.

Estimated code review effort: 1 (Trivial) | ~2 minutes


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@valentinpalkovic valentinpalkovic self-assigned this Jul 24, 2026
@valentinpalkovic valentinpalkovic moved this to In Progress in Core Team Projects Jul 24, 2026
@valentinpalkovic valentinpalkovic added bug ci:normal Run our default set of CI jobs (choose this for most PRs). test utilities labels Jul 24, 2026
@valentinpalkovic
valentinpalkovic merged commit ae7a1f5 into storybookjs:next Jul 24, 2026
137 of 142 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Core Team Projects Jul 24, 2026
@github-actions github-actions Bot mentioned this pull request Jul 24, 2026
2 tasks done
@valentinpalkovic valentinpalkovic added the sev:S2 High priority. Fix within weeks. label Jul 31, 2026
@storybook-app-bot

Copy link
Copy Markdown
Contributor

Package Benchmarks

Commit: 5eb34c4, ran on 31 July 2026 at 09:25:02 UTC

The following packages have significant changes to their size or dependencies:

@storybook/builder-webpack5

Before After Difference
Dependency count 186 186 0
Self size 79 KB 79 KB 🚨 +1 B 🚨
Dependency size 35.73 MB 36.13 MB 🚨 +399 KB 🚨
Bundle Size Analyzer Link Link

storybook

Before After Difference
Dependency count 73 73 0
Self size 21.39 MB 21.31 MB 🎉 -81 KB 🎉
Dependency size 36.75 MB 31.22 MB 🎉 -5.53 MB 🎉
Bundle Size Analyzer Link Link

@storybook/angular

Before After Difference
Dependency count 185 185 0
Self size 160 KB 160 KB 🎉 -54 B 🎉
Dependency size 30.13 MB 30.53 MB 🚨 +399 KB 🚨
Bundle Size Analyzer Link Link

@storybook/angular-vite

Before After Difference
Dependency count 36 36 0
Self size 33.41 MB 33.41 MB 🎉 -2 KB 🎉
Dependency size 21.34 MB 15.80 MB 🎉 -5.54 MB 🎉
Bundle Size Analyzer Link Link

@storybook/ember

Before After Difference
Dependency count 185 185 0
Self size 13 KB 13 KB 0 B
Dependency size 31.08 MB 31.48 MB 🚨 +399 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 531 531 0
Self size 641 KB 640 KB 🎉 -1 KB 🎉
Dependency size 62.41 MB 62.82 MB 🚨 +411 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs-vite

Before After Difference
Dependency count 94 93 🎉 -1 🎉
Self size 1.42 MB 1.37 MB 🎉 -48 KB 🎉
Dependency size 23.91 MB 23.85 MB 🎉 -62 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 125 122 🎉 -3 🎉
Self size 29 KB 29 KB 0 B
Dependency size 25.90 MB 24.91 MB 🎉 -982 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 83 83 0
Self size 32 KB 32 KB 🚨 +8 B 🚨
Dependency size 21.22 MB 21.62 MB 🚨 +398 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 272 272 0
Self size 23 KB 23 KB 0 B
Dependency size 48.19 MB 48.60 MB 🚨 +411 KB 🚨
Bundle Size Analyzer Link Link

@storybook/server-webpack5

Before After Difference
Dependency count 198 198 0
Self size 15 KB 15 KB 0 B
Dependency size 37.00 MB 37.40 MB 🚨 +399 KB 🚨
Bundle Size Analyzer Link Link

@storybook/svelte-vite

Before After Difference
Dependency count 20 20 0
Self size 54 KB 54 KB 🎉 -10 B 🎉
Dependency size 26.65 MB 27.04 MB 🚨 +386 KB 🚨
Bundle Size Analyzer Link Link

@storybook/sveltekit

Before After Difference
Dependency count 21 21 0
Self size 56 KB 56 KB 0 B
Dependency size 26.71 MB 27.09 MB 🚨 +386 KB 🚨
Bundle Size Analyzer Link Link

@storybook/tanstack-react

Before After Difference
Dependency count 84 84 0
Self size 113 KB 112 KB 🎉 -959 B 🎉
Dependency size 21.25 MB 21.65 MB 🚨 +398 KB 🚨
Bundle Size Analyzer Link Link

@storybook/vue3-vite

Before After Difference
Dependency count 103 102 🎉 -1 🎉
Self size 34 KB 34 KB 🎉 -316 B 🎉
Dependency size 43.11 MB 43.04 MB 🎉 -73 KB 🎉
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 205 205 0
Self size 827 KB 827 KB 🚨 +52 B 🚨
Dependency size 91.60 MB 85.99 MB 🎉 -5.61 MB 🎉
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 198 198 0
Self size 32 KB 32 KB 🚨 +36 B 🚨
Dependency size 90.08 MB 84.46 MB 🎉 -5.61 MB 🎉
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 74 74 0
Self size 1.09 MB 1.09 MB 🚨 +53 B 🚨
Dependency size 58.14 MB 52.52 MB 🎉 -5.61 MB 🎉
Bundle Size Analyzer node node

@storybook/preset-react-webpack

Before After Difference
Dependency count 161 161 0
Self size 19 KB 19 KB 🚨 +1 B 🚨
Dependency size 32.70 MB 33.10 MB 🚨 +399 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react

Before After Difference
Dependency count 59 59 0
Self size 1.48 MB 1.49 MB 🚨 +12 KB 🚨
Dependency size 12.30 MB 12.30 MB 🚨 +143 B 🚨
Bundle Size Analyzer Link Link

brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Sep 5, 2026
## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `storybook` | 10.5.10 | 10.6.0 | minor |

## Release Notes

<details>
<summary><b>storybook</b> (10.5.10 → 10.6.0)</summary>

## 10.6.0

> New skills architecture for agentic workflows

Storybook 10.6 contains hundreds of fixes and improvements:

- 💻 CLI bindings for agent tools/skills
- 🅰️ Angular-Vite MCP/skills support and improved docgen/snippets
(experimental)
- 🟢 Vue MCP/skills support and improved docgen/snippets (experimental)
- 🧩 Tanstack / NextJS-Vite framework bugfixes
- ⚡ Improved performance and reduced bundle size

<details>
<summary>List of all updates</summary>

- Addon MCP: Stop silently dropping composed refs from MCP composition -
[#36077](storybookjs/storybook#36077), thanks
@<!---->kasperpeulen!
- Addon Vitest: Pin storybook/test in optimizeDeps so its CJS-only deps
are prebundled -
[#35572](storybookjs/storybook#35572), thanks
@<!---->Nic-Polumeyv!
- Addon Vitest: Report test runs with failures as failed tool outcomes -
[#36080](storybookjs/storybook#36080), thanks
@<!---->kasperpeulen!
- Addon Vitest: Resolve story test globs against the project root -
[#36103](storybookjs/storybook#36103), thanks
@<!---->kasperpeulen!
- Addon-vitest: Filter Storybook instrumentation from reported stack
traces - [#36120](storybookjs/storybook#36120),
thanks @<!---->ghengeveld!
- Angular Vite: Resolve tsConfig against the workspace root -
[#36026](storybookjs/storybook#36026), thanks
@<!---->ndelangen!
- Angular-Vite: Run Compodoc on demand -
[#35776](storybookjs/storybook#35776), thanks
@<!---->valentinpalkovic!
- Angular: Add an in-process docgen analyzer, replacing Compodoc under
the flag -
[#35805](storybookjs/storybook#35805), thanks
@<!---->valentinpalkovic!
- Angular: Bind only what the component accepts in story snippets, and
report the rest -
[#35943](storybookjs/storybook#35943), thanks
@<!---->valentinpalkovic!
- Angular: Decide the migration\'s zone.js import from the dependency
tree - [#36008](https://github.com/story

…[full
notes](https://github.com/storybookjs/storybook/releases/tag/v10.6.0)

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Sep 5, 2026
## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `@storybook/react-vite` | 10.5.10 | 10.6.0 | minor |

## Release Notes

<details>
<summary><b>@<!---->storybook/react-vite</b> (10.5.10 →
10.6.0)</summary>

## 10.6.0

> New skills architecture for agentic workflows

Storybook 10.6 contains hundreds of fixes and improvements:

- 💻 CLI bindings for agent tools/skills
- 🅰️ Angular-Vite MCP/skills support and improved docgen/snippets
(experimental)
- 🟢 Vue MCP/skills support and improved docgen/snippets (experimental)
- 🧩 Tanstack / NextJS-Vite framework bugfixes
- ⚡ Improved performance and reduced bundle size

<details>
<summary>List of all updates</summary>

- Addon MCP: Stop silently dropping composed refs from MCP composition -
[#36077](storybookjs/storybook#36077), thanks
@<!---->kasperpeulen!
- Addon Vitest: Pin storybook/test in optimizeDeps so its CJS-only deps
are prebundled -
[#35572](storybookjs/storybook#35572), thanks
@<!---->Nic-Polumeyv!
- Addon Vitest: Report test runs with failures as failed tool outcomes -
[#36080](storybookjs/storybook#36080), thanks
@<!---->kasperpeulen!
- Addon Vitest: Resolve story test globs against the project root -
[#36103](storybookjs/storybook#36103), thanks
@<!---->kasperpeulen!
- Addon-vitest: Filter Storybook instrumentation from reported stack
traces - [#36120](storybookjs/storybook#36120),
thanks @<!---->ghengeveld!
- Angular Vite: Resolve tsConfig against the workspace root -
[#36026](storybookjs/storybook#36026), thanks
@<!---->ndelangen!
- Angular-Vite: Run Compodoc on demand -
[#35776](storybookjs/storybook#35776), thanks
@<!---->valentinpalkovic!
- Angular: Add an in-process docgen analyzer, replacing Compodoc under
the flag -
[#35805](storybookjs/storybook#35805), thanks
@<!---->valentinpalkovic!
- Angular: Bind only what the component accepts in story snippets, and
report the rest -
[#35943](storybookjs/storybook#35943), thanks
@<!---->valentinpalkovic!
- Angular: Decide the migration\'s zone.js import from the dependency
tree - [#36008](https://github.com/story

…[full
notes](https://github.com/storybookjs/storybook/releases/tag/v10.6.0)

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-scan:mixed bug ci:normal Run our default set of CI jobs (choose this for most PRs). sev:S2 High priority. Fix within weeks. test utilities

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants