0.6.11 • Published 10 months ago
@modern-js/swc-react-const-elements-plugin v0.6.11
Quick Start
Install
npm i swc-plugin-react-const-elements-plugin
Add this to your config
{
"jsc": {
"experimental": {
"plugins": [
[
"@modern-js/swc-react-const-elements-plugin",
{}
]
]
}
}
}
Options
immutableGlobals
- type: string[]
By default all global components are considered mutable, so <Comp />
is never hoisted, if you are sure Comp
is immutable, you can add it to immutableGlobals
like:
{
"jsc": {
"experimental": {
"plugins": [
[
"@modern-js/swc-react-const-elements-plugin",
{
"immutableGlobals": ["Comp"]
}
]
]
}
}
}
allowMutablePropsOnTags
- type: string[]
By default all expression and object literal are considered mutable, so <Card info={{ name: 'modern.js' }} />
is never hoisted, if you are sure Card
is fine if it has mutable props, you can add it to allowMutablePropsOnTags
like:
{
"jsc": {
"experimental": {
"plugins": [
[
"@modern-js/swc-react-const-elements-plugin",
{
"allowMutablePropsOnTags": ["Card"]
}
]
]
}
}
}