core icon indicating copy to clipboard operation
core copied to clipboard

feat(compiler-sfc): defineDirective

Open liuseen-l opened this issue 11 months ago • 3 comments

RFC: https://github.com/vuejs/rfcs/discussions/653

define custom directives will get friendly type hints

// before
<script setup>
      const vTest = defineDirective({ created(){} })
 </script>
// after 
export default {
      setup(__props, { expose: __expose }) {
        __expose();
       const vTest = { created(){} }
       return { vTest }
    }
}

When writing custom directives in a vue file, there is no type hint, so this new micro is added to solve this problem image

liuseen-l avatar Mar 14 '24 05:03 liuseen-l

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 90.5 kB 34.4 kB 31 kB
vue.global.prod.js 148 kB 53.7 kB 47.9 kB

Usages

Name Size Gzip Brotli
createApp 50.8 kB 19.8 kB 18.1 kB
createSSRApp 54.1 kB 21.2 kB 19.3 kB
defineCustomElement 53 kB 20.6 kB 18.8 kB
overall 64.4 kB 24.9 kB 22.6 kB

github-actions[bot] avatar Mar 14 '24 05:03 github-actions[bot]

Why not just use import type { Directive } from 'vue';?

Shyam-Chen avatar Mar 14 '24 08:03 Shyam-Chen

Why not just use import type { Directive } from 'vue';?

This issue is mentioned in the rfc

liuseen-l avatar Mar 14 '24 08:03 liuseen-l