0.6.11 • Published 10 months ago

@modern-js/swc-react-const-elements-plugin v0.6.11

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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"]
          }
        ]
      ]
    }
  }
}
0.6.11

10 months ago

0.6.10

11 months ago

0.6.9

12 months ago

0.6.8

12 months ago

0.6.7

1 year ago

0.6.6

2 years ago

0.6.5

2 years ago

0.6.4

2 years ago

0.6.2

2 years ago

0.6.1

2 years ago