unplugin-vue-autoref
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

unplugin-vue-autoRef npm

More radical reactive tansform macros in Vue powered by Vue Reactivity Transform!


Features

  • ✨ More radical reactive tansform macros in Vue.
  • 💚 Supports both SFC and JSX out-of-the-box.
  • 🦾 Full TypeScript support.
  • ⚡️ Supports Vite, Webpack, Vue CLI, Rollup, esbuild and more, powered by unplugin.

Installation

npm i unplugin-vue-autoref -D
Vite (first-class support)
// vite.config.ts
import AutoRef from 'unplugin-vue-autoref/vite'
import Vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [AutoRef(), Vue({ reactivityTransform: true })],
})


Rollup (first-class support)
// rollup.config.js
import Vue from 'unplugin-vue/rollup'
import AutoRef from 'unplugin-vue-autoref/rollup'

export default {
  plugins: [AutoRef(), Vue({ reactivityTransform: true })], // must be before Vue plugin!
}


esbuild
// esbuild.config.js
import { build } from 'esbuild'

build({
  plugins: [
    require('unplugin-vue-autoref/esbuild')(), // must be before Vue plugin!
    require('unplugin-vue/esbuild')(),
  ],
})


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-vue-autoref/webpack')(), // must be before Vue plugin!
    require('unplugin-vue/webpack')(),
  ],
}


Vue CLI
// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [require('unplugin-vue-autoref/webpack')()],
  },
}


TypeScript Support

// env.d.ts
/// <reference types="unplugin-vue-autoref/autoref-global" />

Usage

<script setup lang="ts">
let count = ref(0)
const updateCount = (num: number) => {
  count += num
}
</script>

<template>
  <button @click="updateCount(-1)">-</button>
  <h1>{{ count }}</h1>
  <button @click="updateCount(1)">+</button>
</template>

Readme

Keywords

none

Package Sidebar

Install

npm i unplugin-vue-autoref

Weekly Downloads

0

Version

0.0.8

License

MIT

Unpacked Size

18.7 kB

Total Files

21

Last publish

Collaborators

  • flippedround