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

Vite: Use Vite 3 (temporarily) #20216

Merged
merged 7 commits into from
Dec 13, 2022
Merged

Vite: Use Vite 3 (temporarily) #20216

merged 7 commits into from
Dec 13, 2022

Conversation

IanVS
Copy link
Member

@IanVS IanVS commented Dec 13, 2022

Issue:

What I did

This implements option D from https://www.notion.so/chromatic-ui/Vite4-support-c986d1e531e34ec7b70b72f4698c0328.

Pseudo-Vite4 support with Vite3

It’s possible that we can support Vite4 projects with Vite3 under the hood temporarily. This would support Vite3 users in the short term, and if we could make it work for Vite4 users it would be the best temporary option since it works today. We’d want to replace this method before the RC.

Blocker: Do users’ Vite4 plugins work with Vite3? IanVS is investigating.

I did this by returning our vite version range to only encompass version 3, so Storybook will continue to use vite 3 for now, but users can upgrade their apps to vite 4 without issue. This should work so long as the newer framework plugins that those users put into their vite.config.js files don't cause problems in vite 3. I tested react locally, and storybook's vite 3 worked fine with the newer @vitejs/plugin-react intended for use with vite 4. I'm not positive all plugins will work that way, but hopefully CI will suss that out, since the repros are using the newer vite + plugins.

I've also forced the older version of the react plugin to be used for mdx processing, removed the react plugin from non-react frameworks, and re-enabled the story disabled in #20210.

How to test

I'm hopeful CI will be instructive here. You could also create a sandbox and try out different versions of packages, but you may need to use --no-link because of version mismatches with the repros.

@IanVS
Copy link
Member Author

IanVS commented Dec 13, 2022

Previously, though I'm not sure why, react fast-refresh was not being added to mdx files. With my first attempts in this PR it was, which was causing problems. I've disabled fast-refresh for mdx files (which @joshwooding can confirm, but I don't think ever worked previously anyway), and I'm hopeful that this will work, but I need to get in bed before CI finishes.

Copy link
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

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

Great quick work! 💪

LGTM if CI passes.

@ndelangen ndelangen merged commit 70f53da into next Dec 13, 2022
@ndelangen ndelangen deleted the vite/force-3 branch December 13, 2022 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants