cloudfour / cloudfour.com-patterns

The design system, component library and documentation for cloudfour.com and related projects
https://cloudfour-patterns.netlify.app
24 stars 3 forks source link

Consider switching from Webpack to Vite #1403

Open tylersticka opened 3 years ago

tylersticka commented 3 years ago

Storybook 6.3 introduces support for bundlers other than Webpack: https://storybook.js.org/blog/storybook-for-vite/

@calebeby pointed out while reviewing a PR by @gerardo-rodriguez that using Vite might simplify the process we've been using for exposing template source code to stories: https://github.com/cloudfour/cloudfour.com-patterns/pull/1402/files#r670882613

Storybook has pluggable bundlers now, so it's not very tied to webpack anymore. But we could make a vite plugin for this syntax if we switched to vite

Unfortunately we haven't upgraded to 6.3 yet because of unresolved regressions related, perhaps ironically, to Webpack. See: #1349

While I don't love the idea of refactoring the project's configuration (which is currently pretty Webpack-centric), if the 6.3 upgrade will require some reconfiguration anyway, we might as well consider switching to a bundler we like better and that might gain us some efficiencies.

Paul-Hebert commented 3 years ago

I've heard good things about Vite! I also don't love the idea of refactoring the config, but I do love the idea of getting experience with Vite!

calebeby commented 3 years ago

I think it would make a lot of sense to switch, here's some reasons:

I'm taking a look to try to size this issue

calebeby commented 3 years ago

Here are things I noticed while testing out the swap:

Conclusion: The lack of caching problem seems like a deal-breaker. I did not look into why it is happening or whether it could be solved. It could be a problem that we have to wait for storybook-builder-vite to solve, or maybe it is a problem that we can fix. Once (if) we can solve that problem, I think the rest of the problems I mentioned seem very solvable.

Giving it a 10. If the lack of caching problem is something that storybook-builder-vite fixes, I think this is a 5.

I pushed my experiments to the vite-experiment branch. The code in there is not very good, when we actually tackle this issue it is probably best to start from scratch, taking ideas (and rollup plugins) from that branch.

calebeby commented 2 years ago

I got stuck on something here... There are a couple stories that don't render correctly. I spent most of yesterday trying to debug it and I couldn't figure it out. I'm gonna take a break from this for a while and hopefully when I come back to it with fresh eyes I'll be able to fix it.

calebeby commented 2 years ago

I realized that most of the issues I was having was due to upgrading twing. Newer versions of twing are asynchronous, while the older version we were using was synchronous. I think it is likely that if I switch back to the old version it will fix the issue I was seeing with a couple stories.

Storybook will eventually have first-class support for async stories: https://github.com/storybookjs/storybook/issues/12726, so when that comes around it will probably be easier to use an async version of twing.

tylersticka commented 2 years ago

It looks like Storybook 7 has added a lot of Vite improvements: https://storybook.js.org/blog/first-class-vite-support-in-storybook/

That issue still looks to be open, though, which is disappointing. Also a little confusing, since it's included in 6.x milestones.