Skip to content
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

Feature: Add Builder-Vite #14024

Closed
blowsie opened this issue Feb 23, 2021 · 10 comments
Closed

Feature: Add Builder-Vite #14024

blowsie opened this issue Feb 23, 2021 · 10 comments

Comments

@blowsie
Copy link

blowsie commented Feb 23, 2021

Is your feature request related to a problem? Please describe
ESM build tools are becoming ever more popular, we have the likes of Vite and Snowpack, which have significant performance and feature improvements over some of the offerings from other tools such as webpack.

Vue 3 and React both have first-class support from Vite

When developing a project with Vite you have to create a simple vite config, to add storybook you would have to maintain a webpack config also.

Describe the solution you'd like
To support Vite projects, ideally consuming the projects vite config.

Describe alternatives you've considered

  • Nothing yet
  • Adding configs for both webpack and vite in my project

Are you able to assist to bring the feature to reality?
I would happily contribute as much as I am technically capable, or provide demo cases and testing.

Additional context

Vite

https://vitejs.dev/
https://www.youtube.com/watch?v=xXrhg26VCSc

@shilman
Copy link
Member

shilman commented Feb 23, 2021

100% interested in exploring this. Our builder abstraction is still immature--lots to figure out to make this a reality.

@eirslett
Copy link
Contributor

eirslett commented Apr 4, 2021

I'll just leave this link here: there is some community work going on for Vite support: https://github.com/SasanFarrokh/storybook/tree/vite-support

@shilman
Copy link
Member

shilman commented Apr 5, 2021

And here's a WIP strawman for how we plan to incorporate new builders into the Storybook ecosystem:

https://docs.google.com/document/d/1M3pFGLCnZLec78p3fFkWvei-ajnpn1BXjzjd93TGvRs/edit?usp=sharing

I'm hoping that we can agree on a mechanism for allowing community builders this week and release it in 6.3-alpha next week.

@shilman
Copy link
Member

shilman commented Apr 26, 2021

https://github.com/eirslett/storybook-builder-vite

@o-alexandrov
Copy link

o-alexandrov commented Jun 2, 2021

Vite's builder from eirslett has an open HMR issue on the Storybook's side.
Reproducible with the example in this repo.

  • HMR works for Vite-managed parts (actual components used in stories), but doesn't work for Storybook-managed parts (thru Webpack)

Ideally, 3rd party builders replace Webpack completely; that's how I believe most of us would think @storybook/*/standalone should work.

  • also would be great, if those, who are using the standalone version or 3rd party bundlers/builders, won't need to download the dependencies related to the default bundling (webpack 4, etc.)

@o-alexandrov
Copy link

@shilman could you please share @storybookjs plans on fixing it?

  • so it'd be easier for Storybook users to make bundling-related decisions

Using nodemon to reload **/*.stories.* doesn't work, resulting in an error when files are updated and after trying random reload libraries, only a custom script with chokidar helps to manually close the process and run storybook again.

It'd be reassuring to know Storybook acknowledges the existence of HMR issue and plans to work on it thru community or itself.

@shilman
Copy link
Member

shilman commented Jun 7, 2021

@o-alexandrov is there an open issue in the storybook monorepo? if so, can you share a link, and if not, can you create one?

@shilman
Copy link
Member

shilman commented Jun 10, 2021

@o-alexandrov Ok I understand the question better now after chatting with @IanVS

This is primarily a vite-builder issue. Builders are 100% responsible for Storybook's preview iframe in the current architecture, and as far as I know have all the information they need to implement HMR for both components and stories.

There may be more changes needed on the Storybook side. For example, we've been making change on the storybook side to make our libraries/addons more ESM-friendly, driven by builder-vite (or some other builder-X) requirements. But until I hear otherwise this is not a Storybook issue.

@IanVS is going to start looking at this issue tomorrow in the vite builder. As usual, we will do our best to turn around any issues in Storybook core as quickly as possible to keep this work unblocked.

I'm going to close this issue for now, and further discussion on any aspect of the Vite builder can happen on the builder-vite repo: https://github.com/eirslett/storybook-builder-vite

I'll open a new issue if/when we decide to integrate builder-vite into core. Thanks!

@blowsie
Copy link
Author

blowsie commented Oct 22, 2021

I just popped by to say, Vite is proving to be the next best thing since sliced bread, I hope that one day storybook officially runs on Vite by default ;)

@shilman
Copy link
Member

shilman commented Oct 22, 2021

@blowsie not ruling it out by any means!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants