1.0.9 • Published 10 months ago
unplugin-vue-jsx-vapor v1.0.9
unplugin-vue-jsx-vapor
Convert Vue JSX to Vapor.
Install
npm i unplugin-vue-jsx-vapor
!CAUTION ❌ The destructuring of props in a functional component will cause loss of reactivity.
function Comp({ foo }) {
return <div>{foo}</div>
}
const foo = ref('foo')
export default <Comp foo={foo.value} />
Two Solutions
- ✅ Pass a ref variable as prop:
function Comp({ foo }) {
return <div>{foo.value}</div>
}
const foo = ref('foo')
export default <Comp foo={foo} />
- ✅ Use the
defineComponent
macro from @vue-macros/jsx-macros to wrapping.
defineComponent(({ foo }) => {
return <div>{ foo }<div>
})
function Comp({ foo }) {
return <div>{foo}</div>
}
// Will be convert to:
function Comp(_ctx0) {
return <div>{_ctx0.foo}</div>
}
const foo = ref('foo')
export default <Comp foo={foo.value} />
// vite.config.ts
import VueJsxVapor from 'unplugin-vue-jsx-vapor/vite'
export default defineConfig({
plugins: [VueJsxVapor()],
})
Example: playground/
// rollup.config.js
import VueJsxVapor from 'unplugin-vue-jsx-vapor/rollup'
export default {
plugins: [VueJsxVapor()],
}
// webpack.config.js
module.exports = {
/* ... */
plugins: [require('unplugin-vue-jsx-vapor/webpack')()],
}
// nuxt.config.js
export default defineNuxtConfig({
modules: ['unplugin-vue-jsx-vapor/nuxt'],
})
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [require('unplugin-vue-jsx-vapor/webpack')()],
},
}
// esbuild.config.js
import { build } from 'esbuild'
import VueJsxVapor from 'unplugin-vue-jsx-vapor/esbuild'
build({
plugins: [VueJsxVapor()],
})
1.0.9
10 months ago
1.0.8
11 months ago
1.0.7
11 months ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago
1.0.6
11 months ago
1.0.5
11 months ago
1.0.4
1 year ago
1.0.3
1 year ago
0.2.1
1 year ago
0.2.0
1 year ago
0.2.7
1 year ago
0.2.6
1 year ago
0.2.3
1 year ago
0.2.2
1 year ago
0.2.5
1 year ago
0.2.4
1 year ago
0.1.20
1 year ago
0.1.19
1 year ago
0.1.18
1 year ago
0.1.15
1 year ago
0.1.16
1 year ago
0.1.17
1 year ago
0.1.14
1 year ago
0.1.12
1 year ago
0.1.13
1 year ago
0.1.11
1 year ago
0.1.10
1 year ago
0.1.8
1 year ago
0.1.7
1 year ago
0.1.9
1 year ago
0.1.6
1 year ago
0.1.5
1 year ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago