1.0.9 • Published 8 months ago

unplugin-vue-jsx-vapor v1.0.9

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

unplugin-vue-jsx-vapor

NPM version

Convert Vue JSX to Vapor.

Playground

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

  1. ✅ Pass a ref variable as prop:
function Comp({ foo }) {
  return <div>{foo.value}</div>
}

const foo = ref('foo')
export default <Comp foo={foo} />
  1. ✅ 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

8 months ago

1.0.8

9 months ago

1.0.7

10 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

11 months ago

1.0.3

11 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.2.7

11 months ago

0.2.6

12 months ago

0.2.3

12 months ago

0.2.2

12 months ago

0.2.5

12 months ago

0.2.4

12 months 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

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago