Closed sar closed 1 year ago
This is hardcoded mostly because I did not see the need for a config.
I can add an option, but this plugin is only used in dev, so the build pipeline for vite need to support this as well. Is it the case for you?
If you need this for both dev and build, you can look at https://github.com/egoist/unplugin-swc
Edit: I just found that this plugin doesn't do fast refresh in dev. Which can be limiting.
Testing in dev. Some environments require tweaking swcrc
, it'd be useful to add support for an optional config param.
Can you tell me if just changing swcrc
to true in the node_modules does what you expect?
If it works I can make it a plugin parameter, otherwise I need to look a bit more at how config loading & options merging works in swc
Hi! After discussion with the core team, we decided to make this plugin official and keep the SWC configuration off.
If someone want to propose a use-case for it, please open a new issue to discuss it.
Thanks for your work on this project! Just updated to the new version of Vite and wanted to try this out.
There is a swc plugin for styled components but I can't currently use it duebecause of this issue. This wasn't a problem on the babel plugin due to being able to specify plugins
react({
babel: {
plugins: [['babel-plugin-styled-components', { pure: true }]],
},
})
Thanks for reaching out.
We don't plan to support all use cases with this default plugin, but depending on the complexity and the need we could add an option for some use cases that have a good benefits/performance ratio.
Can you tell me if using an .swcrc
file and changing this line to true in your node_modueles works for you?
Letting SWC resolve the configuration would be a good tradeoff, but would still make the caching feature I'm working on a bit more complex.
Can you tell me if using an
.swcrc
file and changing this line to rue in your node_modueles works for you?
Overriding parameter swcrc: true
in /node_modules/.../swc-react-refresh.js
does fix it, correctly parses swc config from project root. Can you make it a plugin option?
should there be a base swc plugin for configuring the the .swcrc
file instead? I doubt this plugin will be the last thing to want to use swc.
I was a bit optimist yesterday, I totally forgot that this would require more work to support SWC at build time.
Tracking this in https://github.com/vitejs/vite-plugin-react-swc/issues/16
Add support for usage of external
.swcrc
configuration file as optional parameter passed toswcReactRefresh()
.Example
Issue
Swc config appears to be hardcoded in-line and plugin does not respect
.swcrc
in rootDir. For example, adding changes like"transform" { "legacyDecorator": true }
are not picked up by the plugin.https://github.com/ArnaudBarre/vite-plugin-swc-react-refresh/blob/95291df10ecc2e1ec076db2f771e03fcd465fa64/src/swc-react-refresh.ts#L45-L62
Is overriding defaults supported (might be documentation issue)?