0.3.0 • Published 3 months ago

swc-plugin-vue-jsx v0.3.0

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

SWC Plugin for Vue JSX

SWC plugin for transforming Vue JSX, mostly ported from official Babel plugin. It only supports Vue.js v3 or newer.

Installation

npm i -D swc-plugin-vue-jsx

Configuration

You can configure your .swcrc file.

Minimum Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": true
    },
    "experimental": {
      "plugins": [["swc-plugin-vue-jsx", {}]]
    }
  }
}

Options

These options of official Babel plugin are supported:

  • transformOn
  • optimize
  • mergeProps
  • enableObjectSlots
  • pragma

For details, please refer to official documentation.

The isCustomElement can't be supported directly, because SWC config only allows JSON, so we introduce the customElementPatterns option instead.

It accepts an array of strings which represent regex.

For example:

[
  "swc-plugin-vue-jsx",
  {
    "customElementPatterns": ["^i-"]
  }
]

All HTML tags which match the pattern ^i- will be treated as custom elements.

Advanced Config Example

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": true
    },
    "experimental": {
      "plugins": [
        [
          "swc-plugin-vue-jsx",
          {
            "transformOn": true,
            "optimize": true
          }
        ]
      ]
    }
  }
}

License

MIT License

Copyright (c) 2022-present Pig Fang

0.3.0

3 months ago

0.2.7

4 months ago

0.2.6

6 months ago

0.2.5

10 months ago

0.2.1

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.4

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago