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: Detect React SWC plugin #20335

Merged
merged 1 commit into from
Dec 20, 2022
Merged

Vite: Detect React SWC plugin #20335

merged 1 commit into from
Dec 20, 2022

Conversation

IanVS
Copy link
Member

@IanVS IanVS commented Dec 20, 2022

Issue:

There's now two vite plugins for react, one with babel, and one with SWC. We were not detecting the swc plugin, so ended up adding the fallback babel version, which conflicted and caused errors

What I did

Detect the swc react vite plugin.

How to test

Do we want a sandbox for this?

npm create vite // ---> choose react,  TypeScript + SWC
npx sb@next init
// build react-vite, copy the dist in, it works.

@ndelangen ndelangen self-assigned this Dec 20, 2022
@ndelangen ndelangen merged commit b48942e into next Dec 20, 2022
@ndelangen ndelangen deleted the vite/swc-react branch December 20, 2022 09:11
@FezVrasta
Copy link
Contributor

Any chance to backport this to 6.x? I get an error if I try to use SWC with builder-vite 0.4.2

ERR! Error: Cannot find module '@vitejs/plugin-react'

@IanVS
Copy link
Member Author

IanVS commented Mar 27, 2023

The architecture of the two are quite different. In 6.5 we always inject the plugin. If you want to use swc in 6.5, you could use viteFinal to filter out the react plugin that storybook adds and then inject the swc plugin instead.

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