From adaf9a53a4a23ae60a150ed7ff2f05f378d7610f Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 4 Jan 2021 01:44:39 -0500 Subject: [PATCH] docs: plugin-vue-jsx --- packages/plugin-vue-jsx/README.md | 50 ++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/packages/plugin-vue-jsx/README.md b/packages/plugin-vue-jsx/README.md index fcac9473..cb05fb59 100644 --- a/packages/plugin-vue-jsx/README.md +++ b/packages/plugin-vue-jsx/README.md @@ -1,14 +1,56 @@ # @vitejs/plugin-vue-jsx -Provides optimized Vue 3 JSX support via [@vue/babel-plugin-jsx](https://github.com/vuejs/jsx-next). +Provides Vue 3 JSX & TSX support with HMR. ```js // vite.config.js import vueJsx from '@vitejs/plugin-vue-jsx' export default { - plugins: [vueJsx({ - // options are passed on to @vue/babel-plugin-jsx - })] + plugins: [ + vueJsx({ + // options are passed on to @vue/babel-plugin-jsx + }) + ] } ``` + +## Options + +See [@vue/babel-plugin-jsx](https://github.com/vuejs/jsx-next). +## HMR Detection + +This plugin supports HMR of Vue JSX components. The detection requirements are: + +- The component must be exported. +- The component must be declared by calling `defineComponent` via a root-level statement, either variable declaration or export declaration. + +### Supported patterns + +```jsx +import { defineComponent } from 'vue' + +// named exports w/ variable declaration: ok +export const Foo = defineComponent(...) + +// named exports referencing vairable declaration: ok +const Bar = defineComponent(...) +export { Bar } + +// default export call: ok +export default defineComponent(...) + +// default export referencing variable declaration: ok +const Baz = defineComponent(...) +export default Baz +``` + +### Non-supported patterns + +```jsx +// not using `defineComponent` call +export const Bar = { ... } + +// not exported +const Foo = defineComponent(...) +``` \ No newline at end of file