Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/g-plane/swc-plugin-vue-jsx
SWC plugin for transforming Vue JSX.
https://github.com/g-plane/swc-plugin-vue-jsx
jsx swc-plugin vue
Last synced: 7 days ago
JSON representation
SWC plugin for transforming Vue JSX.
- Host: GitHub
- URL: https://github.com/g-plane/swc-plugin-vue-jsx
- Owner: g-plane
- License: mit
- Created: 2022-10-18T00:41:39.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-29T02:42:28.000Z (26 days ago)
- Last Synced: 2024-12-16T13:12:33.162Z (9 days ago)
- Topics: jsx, swc-plugin, vue
- Language: Rust
- Homepage: https://www.npmjs.com/package/swc-plugin-vue-jsx
- Size: 286 KB
- Stars: 94
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SWC Plugin for Vue JSX
SWC plugin for transforming Vue JSX, mostly ported from [official Babel plugin](https://github.com/vuejs/babel-plugin-jsx).
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
```json
{
"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`
- `resolveType` (Types imported from other modules aren't supported.)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:
```json
[
"swc-plugin-vue-jsx",
{
"customElementPatterns": ["^i-"]
}
]
```All HTML tags which match the pattern `^i-` will be treated as custom elements.
### Advanced Config Example
```json
{
"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