Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

Closes #

What I did

Added automigration nextjs-to-nextjs-vite that installs vite@^7.0.0 as a devDependency when migrating from @storybook/nextjs to @storybook/nextjs-vite if vite isn't already present. This prevents broken projects when migrating from webpack-based Next.js to the new Vite-based framework.

Implementation details:

  • Detects @storybook/nextjs presence via package manager
  • Replaces framework package and updates main config + import statements
  • Conditionally adds vite based on getDependencyVersion('vite') check
  • Exported VITE_DEFAULT_VERSION constant for version consistency

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!

No manual testing required. The automigration logic is fully covered by unit tests that verify both scenarios: when vite is already installed and when it needs to be added.

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 publish.yml --field pr=<PR_NUMBER>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 9, 2025 18:18
- Add getDependencyVersion mock to package manager in tests
- Split test into two scenarios: with and without vite installed
- Test that vite@^7.0.0 is added when vite is not installed
- Test that vite is not added when already installed

Co-authored-by: valentinpalkovic <[email protected]>
- Add VITE_DEFAULT_VERSION constant in both implementation and tests
- Add comment explaining explicit mock setup in test for clarity
- Update test to use constant instead of hardcoded version

Co-authored-by: valentinpalkovic <[email protected]>
- Export constant from main file to maintain single source of truth
- Import constant in test file instead of duplicating
- Remove redundant mock setup that was already done in beforeEach

Co-authored-by: valentinpalkovic <[email protected]>
Copilot AI changed the title [WIP] Add vite installation during Nextjs-Vite migration Nextjs-Vite: Install vite during migration if not installed yet Dec 9, 2025
@valentinpalkovic valentinpalkovic marked this pull request as ready for review December 9, 2025 18:39
@valentinpalkovic valentinpalkovic merged commit 3461e40 into nextjs-vite-automigration-add-vite Dec 9, 2025
@valentinpalkovic valentinpalkovic deleted the copilot/sub-pr-33316 branch December 9, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants