vitejs / vite-plugin-react-swc

Speed up your Vite dev server with SWC
MIT License
834 stars 54 forks source link

Support SWC configuration #16

Closed ArnaudBarre closed 1 year ago

ArnaudBarre commented 1 year ago

The current version of the plugin is used only in development.

Adding SWC configuration requires to also run it during the build phase.

This require some work, but could be done if there is enough people asking for it (please like the issue and don't comment +1).

We don't plan to support every use case, the babel plugin will still be available for people who want to keep using classic runtime for example.

Use cases for it:

Update:

A beta release is available with support for decorators in TS and plugins via the JS API: https://github.com/vitejs/vite-plugin-react-swc/releases/tag/v3.1.0-beta.2

.swcrc or other configuration are not supported for now. The goal is to keep the configuration surface small so that I can support most use cases and still enable caching later on. If your need is not currently covered, share it in comment.

jurosh commented 1 year ago

This is super needed for styled comps. Eg. to add names to styled components and make inspecting elements easy. This works in non-swc plugin:

babel: { plugins: [['babel-plugin-styled-components', { ssr: false, pure: true, displayName: true, fileName: true }]]  }
glekner commented 1 year ago

This looks like a needed addition

UzEE commented 1 year ago

This will be extremely useful for enabling decorator support as well. As it stands, we aren't able to migrate our codebase over from Webpack + Babel since we can't take advantage of fast refreshes enabled by SWC.

declanchiu commented 1 year ago

This will be extremely useful for enabling decorator support as well. As it stands, we aren't able to migrate our codebase over from Webpack + Babel since we can't take advantage of fast refreshes enabled by SWC.这对于启用装饰器支持也非常有用。就目前而言,我们无法将我们的代码库从 Webpack Babel 迁移过来,因为我们无法利用 SWC 启用的快速刷新。

Our team is also stuck in this place

ghost commented 1 year ago

@UzEE @PlayGuitar-CoderQ The readme shows you can enable ts decorators, but I've never tried it: https://github.com/vitejs/vite-plugin-react-swc#tsdecorators

UzEE commented 1 year ago

@jrobeson Yes, the support was added recently into the main branch, so I'm hopeful it will land at least in an alpha or a beta release soon.

notmedia commented 1 year ago

@ArnaudBarre Hi! Could you publish new release for us? We are waiting for decorators support 🙏

ArnaudBarre commented 1 year ago

A beta release is available: 3.1.0-beta.2

Changelog: https://github.com/vitejs/vite-plugin-react-swc/releases/tag/v3.1.0-beta.2

guoyunhe commented 1 year ago

Can you make a production release of 3.1.0?

ArnaudBarre commented 1 year ago

I'm closing this issue with the release of 3.1 that makes tsDecorators and plugins stable. If you have new configuration needs open a new issue to present your use case and discuss it!