Skip to content

feat: Add Vite 7 support #800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: Add Vite 7 support #800

wants to merge 3 commits into from

Conversation

hugoattal
Copy link
Collaborator

Fix #798, #792

Description

Update to Vite 7 and update vite-node.

Copy link

codesandbox bot commented Jun 27, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

netlify bot commented Jun 27, 2025

Deploy Preview for histoire-examples-svelte3 failed.

Name Link
🔨 Latest commit 310bed4
🔍 Latest deploy log https://app.netlify.com/projects/histoire-examples-svelte3/deploys/6866caca46971a000894e1fd

Copy link

netlify bot commented Jun 27, 2025

Deploy Preview for histoire-examples-vue3 failed.

Name Link
🔨 Latest commit 310bed4
🔍 Latest deploy log https://app.netlify.com/projects/histoire-examples-vue3/deploys/6866caca79171f00087c35b3

Copy link

netlify bot commented Jun 27, 2025

Deploy Preview for histoire-site failed.

Name Link
🔨 Latest commit 310bed4
🔍 Latest deploy log https://app.netlify.com/projects/histoire-site/deploys/6866caca8e724400089e40f3

Copy link

netlify bot commented Jun 27, 2025

Deploy Preview for histoire-controls failed.

Name Link
🔨 Latest commit 310bed4
🔍 Latest deploy log https://app.netlify.com/projects/histoire-controls/deploys/6866caca8e724400089e40f5

@hugoattal hugoattal changed the title Update packages + fix type feat: Add Vite 7 support Jun 27, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @hugoattal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on a significant dependency upgrade, moving the project to Vite 7 and updating vite-node. This update aims to improve overall performance, leverage new features from these tools, and maintain compatibility with the latest ecosystem standards. I've also addressed any immediate type-related issues that arose from these upgrades.

Highlights

  • Dependency Upgrades: I've upgraded the core Vite dependency across the entire monorepo, including all examples and internal packages, from version 6.x to 7.0.0. This brings the project up to date with the latest Vite features and performance improvements.
  • Vite-Node Update: The vite-node dependency has been updated from 0.34.7 to 3.2.4 in the main histoire package, ensuring compatibility and leveraging improvements in the test runner and development environment.
  • Type Compatibility Fixes: I've introduced minor type fixes in packages/histoire/src/node/build.ts and packages/histoire/src/node/vite.ts to address breaking changes or stricter type checking introduced by the Vite 7 upgrade, ensuring the codebase remains type-safe.
  • Lockfile Synchronization: The pnpm-lock.yaml file has been comprehensively updated to reflect all new dependency versions, including transitive updates for rollup, esbuild, postcss, es-module-lexer, debug, and nanoid, ensuring a consistent and reproducible build environment.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

pkg-pr-new bot commented Jun 27, 2025

Open in StackBlitz

histoire

npm i https://pkg.pr.new/histoire-dev/histoire@800

@histoire/app

npm i https://pkg.pr.new/histoire-dev/histoire/@histoire/app@800

@histoire/controls

npm i https://pkg.pr.new/histoire-dev/histoire/@histoire/controls@800

@histoire/plugin-nuxt

npm i https://pkg.pr.new/histoire-dev/histoire/@histoire/plugin-nuxt@800

@histoire/plugin-percy

npm i https://pkg.pr.new/histoire-dev/histoire/@histoire/plugin-percy@800

@histoire/plugin-screenshot

npm i https://pkg.pr.new/histoire-dev/histoire/@histoire/plugin-screenshot@800

@histoire/plugin-svelte

npm i https://pkg.pr.new/histoire-dev/histoire/@histoire/plugin-svelte@800

@histoire/plugin-vue

npm i https://pkg.pr.new/histoire-dev/histoire/@histoire/plugin-vue@800

@histoire/shared

npm i https://pkg.pr.new/histoire-dev/histoire/@histoire/shared@800

@histoire/vendors

npm i https://pkg.pr.new/histoire-dev/histoire/@histoire/vendors@800

commit: 310bed4

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the project to support Vite 7 by bumping the vite dependency across all packages and also updating vite-node. The changes in package.json and pnpm-lock.yaml files are consistent with this goal.

I've identified a couple of areas in the TypeScript code where type-related workarounds have been introduced, likely to resolve issues from the dependency upgrades. I've left specific suggestions to improve the type safety and maintainability of these changes. Overall, the changes look good and align with the PR's objective.

@@ -133,6 +133,7 @@ export async function build(ctx: Context) {
},
})
}
// @ts-expect-error vue plugin use function form

Choose a reason for hiding this comment

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

medium

While using @ts-expect-error is acceptable for handling type issues from external libraries, the accompanying comment vue plugin use function form is a bit cryptic. For better long-term maintainability, it would be helpful to add a more descriptive comment explaining why this is necessary.

For example:

// HACK: Manually trigger the vue plugin's configureServer hook.
// This is needed because we create a new Vite server instance for the build,
// and the Vue plugin needs to be configured with this new instance.
// @ts-expect-error The 'configureServer' hook can be an object, but we assume it's a function here.

This provides more context for future developers who might encounter this code.

Comment on lines +157 to 159
(this.meta as any).histoire = {
isCollecting: isServer,
}

Choose a reason for hiding this comment

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

medium

Using as any to bypass type checking should be avoided as it can hide potential bugs and makes the code harder to maintain. It seems the goal is to add a custom histoire property to the plugin context's meta object.

A better, type-safe approach would be to use declaration merging to augment the PluginContextMeta interface from Rollup. You can add a histoire.d.ts file in your project (e.g., in the src directory) with the following content:

// histoire.d.ts
import 'rollup'

declare module 'rollup' {
  export interface PluginContextMeta {
    histoire?: {
      isCollecting: boolean
    }
  }
}

Make sure this file is included in your tsconfig.json. This will make the histoire property available on this.meta in a type-safe way, and you can revert this change.

As a less invasive alternative, using bracket notation is safer than as any and would also resolve the type error:

Suggested change
(this.meta as any).histoire = {
isCollecting: isServer,
}
this.meta['histoire'] = {
isCollecting: isServer,
}

@hugoattal
Copy link
Collaborator Author

I have no idea how to fix this error with vite-node:

Error while collecting story C:/Users/hugoa/Documents/git/histoire/examples/vue3/node_modules/.histoire/plugins/builtin_tailwind-tokens/Tailwind.story.js:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'histoire-style' imported from C:\Users\hugoa\Documents\git\histoire\examples\vue3\node_modules\.histoire\plugins\builtin_tailwind-tokens\Tailwind.story.js

I've been trying to fix it a long time ago, the plugin is correctly loaded, and server.config.resolve.alias (in node/server.ts) gives this:

[
  {
    find: 'histoire-style',
    replacement: 'C:/Users/hugoa/Documents/git/histoire/packages/histoire-app/dist/style.css'
  },
  {
    find: /^\/?@vite\/env/,
    replacement: '/@fs/C:/Users/hugoa/Documents/git/histoire/node_modules/.pnpm/[email protected]_@[email protected]_6bc24ac55c5c50238b0c8b5683cd6055/node_modules/vite/dist/client/env.mjs'
  },
  {
    find: /^\/?@vite\/client/,
    replacement: '/@fs/C:/Users/hugoa/Documents/git/histoire/node_modules/.pnpm/[email protected]_@[email protected]_6bc24ac55c5c50238b0c8b5683cd6055/node_modules/vite/dist/client/client.mjs'
  }
]

@hugoattal
Copy link
Collaborator Author

hugoattal commented Jul 3, 2025

I have commented out those two imports that seems to break everything:

// import 'histoire-style'
// import './style.css'

I once again spent hours on this with no lead 😅... This seems to be a vite-node update, but I have no clue how to fix it. Except maybe hard-code the location of the css file.

In the nodes/collect/worker.ts, this works:

console.log(await runner.resolveUrl("histoire-style")); //This does return the correct URL

So I don't understand why on earth why this fail:

const { default: Comp } = await import(/* @vite-ignore */ file.moduleId)

With

[ERR_MODULE_NOT_FOUND]: Cannot find package 'histoire-style' imported from C:\Users\hugoa\Documents\git\histoire\examples\vue3\node_modules\.histoire\plugins\builtin_tailwind-tokens\Tailwind.story.js

Even with hard-coding the style file path, I get this:

Error while collecting story C:/Users/hugoa/Documents/git/histoire/examples/vue3/node_modules/.histoire/plugins/builtin_tailwind-tokens/Tailwind.story.js:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".css" for C:\Users\hugoa\Documents\git\histoire\packages\histoire-app\dist\style.css

I think vite-node needs to be tweaked, but since there's no documentation, I can't figure it out...

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.

Vite 7 support
2 participants