Addon Vitest: Support init in Vitest >= 3.2#31715
Conversation
|
View your CI Pipeline Execution ↗ for commit 29b367b.
☁️ Nx Cloud last updated this comment at |
6cab441 to
af7fb1b
Compare
There was a problem hiding this comment.
7 files reviewed, 4 comments
Edit PR Review Bot Settings | Greptile
| // Use `workspace` field in Vitest < 3.2 | ||
| projects: [{ |
There was a problem hiding this comment.
syntax: Comment implies this field should be used for Vitest < 3.2, but it's actually for >= 3.2. Update comment to avoid confusion.
| // Use `workspace` field in Vitest < 3.2 | ||
| projects: [{ |
There was a problem hiding this comment.
syntax: Same incorrect comment about Vitest version compatibility in Vue template.
| // Use `workspace` field in Vitest < 3.2 | ||
| projects: [{ |
There was a problem hiding this comment.
syntax: Same incorrect comment about Vitest version compatibility in Svelte template.
| const hasWorkspaceConfig = configFile.includes('workspace:'); | ||
| const hasProjectsConfig = configFile.includes('projects:'); | ||
| const configFileHasTypeReference = configFile.match( | ||
| /\/\/\/\s*<reference\s+types=["']vitest\/config["']\s*\/>/ | ||
| ); |
There was a problem hiding this comment.
logic: ensure both workspace: and projects: checks are using strict string matching (e.g., /\bworkspace:\b/.test(configFile)) to avoid false positives
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 49 | 49 | 0 |
| Self size | 31.85 MB | 31.87 MB | 🚨 +16 KB 🚨 |
| Dependency size | 17.41 MB | 17.41 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 531 | 531 | 0 |
| Self size | 217 KB | 902 KB | 🚨 +686 KB 🚨 |
| Dependency size | 58.92 MB | 58.92 MB | 🚨 +172 B 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 131 | 131 | 0 |
| Self size | 2.39 MB | 3.07 MB | 🚨 +685 KB 🚨 |
| Dependency size | 22.30 MB | 22.30 MB | 🚨 +500 B 🚨 |
| Bundle Size Analyzer | Link | Link |
sb
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 50 | 50 | 0 |
| Self size | 1 KB | 1 KB | 0 B |
| Dependency size | 49.26 MB | 49.27 MB | 🚨 +16 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 216 | 216 | 0 |
| Self size | 582 KB | 582 KB | 0 B |
| Dependency size | 94.58 MB | 94.59 MB | 🚨 +16 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 185 | 185 | 0 |
| Self size | 31 KB | 31 KB | 0 B |
| Dependency size | 78.71 MB | 78.72 MB | 🚨 +16 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
… dependency order
…Vitest and load optimizeDeps preset
…Candidates for optimized resolution
…S and streamline dependency resolution
…hancing compatibility with plugins
|
|
||
| const extension = extname(rootConfig).includes('ts') ? '.ts' : '.js'; | ||
| const newWorkspaceFile = resolve(dirname(rootConfig), `vitest.workspace${extension}`); | ||
| const workspaceTemplate = await loadTemplate('vitest.workspace.template.ts', { |
There was a problem hiding this comment.
should the vitest.workspace.template.ts file be deleted then, or is it still being used somewhere?
There was a problem hiding this comment.
It is still used in the case the user has an existing workspace file.
|
|
||
| <details id="example-vitest-workspace"> | ||
| <summary>Example Vitest workspace file</summary> | ||
| <summary>Example Vitest workspace file (Vitest < 3.2)</summary> |
There was a problem hiding this comment.
I'd think it makes more sense to remove this section altogether, now that the example config file already has everything, including pre and post Vitest 3.2?
And also adjust https://github.com/storybookjs/storybook/pull/31715/files#diff-64c8d1c5581a216a909dc8ece0c8611404e6add0ec5d6f9faecdec6ae300dbbeR66 to not mention a separate worksapce file.
cc @kylegach
There was a problem hiding this comment.
That's what I wanted to do initially, but @yannbf vetoed and wanted to keep the documentation for people who already have a workspace configuration in place.
Addon Vitest: Support init in Vitest >= 3.2 (cherry picked from commit 1cce824)
Closes #31689
What I did
projectsfield when initializing Addon Vitest for Vitest 3.2 usersoptimizeDepsto@storybook/addon-vitestChecklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake 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 pull request has been released as version
0.0.0-pr-31715-sha-b9a0ceb9. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-31715-sha-b9a0ceb9 sandboxor in an existing project withnpx storybook@0.0.0-pr-31715-sha-b9a0ceb9 upgrade.More information
0.0.0-pr-31715-sha-b9a0ceb9valentin/support-vitest-3-2b9a0ceb91749823661)To request a new release of this pull request, mention the
@storybookjs/coreteam.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=31715Greptile Summary
Updates the Vitest addon to support Vitest >= 3.2 by using the
projectsfield instead of the deprecated workspace file configuration.vitest.config.3.2.template.tsutilizing theprojectsarray instead of workspace config