[RFC]: Add function type config, and overrides ability for tools.swc #4268
Replies: 7 comments
-
Can we implement this in the framework level? EdenX framework provides a tools.swc config, we can enhance it and support function type, just like |
Beta Was this translation helpful? Give feedback.
-
Yeah, that is what I thought, all the examples above, is for |
Beta Was this translation helpful? Give feedback.
-
Do we really need a It seems we are using different swc configs for different files. If users configure it, it may be difficult to migrate to Rspack in the future. |
Beta Was this translation helpful? Give feedback.
-
Overrides is just for framework level, under the hood it will just become different module.rules, like:
So we don't have to modify bindings |
Beta Was this translation helpful? Give feedback.
-
Get, but we do not provide this feature for Babel, so I'm wondering if we need to provide it for SWC. Is there some real business needs here? |
Beta Was this translation helpful? Give feedback.
-
It can be an escape when we encounter some tricky SWC transform issues, and only appear in one file and with some configs. For example |
Beta Was this translation helpful? Give feedback.
-
Get, it makes sense. |
Beta Was this translation helpful? Give feedback.
-
What problem does this feature solve?
Some users need more detailed control of SWC, and there are many many configurations in SWC, currently
builder-plugin-swc
only exposes some frequently used options, like thereact
andenv
fields of SWC configurations.But some users may need some more config that we do not notice, like for mobx users, they need to set
useDefineforClass
option, I've never noticed this before, and I cannot guarantee that I can take all the configs into account in the future either, so it's necessary for users to have full control of SWC.Function type config support
We can use function type config, and let users have full control of SWC. we pass the whole config and some utilities to it, give our users abilities to modify the whole config
Overrides config
Some users wanted that, enable a specific plugin only in file foo, and enable other plugins in file bar. Or if SWC minimizer has bugs in some files, we can disable minimize only in those files. It's similar to babel's overrides
What does the proposed API look like?
We can support function type config, and pass some useful utilities.
And overrides like:
Object config:
Function config:
Beta Was this translation helpful? Give feedback.
All reactions