You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.2 KiB

1 month ago
  1. ## @vue/babel-preset-jsx
  2. Configurable preset for Vue JSX plugins.
  3. ### Babel Compatibility Notes
  4. - This repo is only compatible with Babel 7.x, for 6.x please use [vuejs/babel-plugin-transform-vue-jsx](https://github.com/vuejs/babel-plugin-transform-vue-jsx)
  5. ### Usage
  6. Install the dependencies:
  7. ```sh
  8. # for yarn:
  9. yarn add @vue/babel-preset-jsx @vue/babel-helper-vue-jsx-merge-props
  10. # for npm:
  11. npm install @vue/babel-preset-jsx @vue/babel-helper-vue-jsx-merge-props --save
  12. ```
  13. In your `babel.config.js`:
  14. ```js
  15. module.exports = {
  16. presets: ['@vue/babel-preset-jsx'],
  17. }
  18. ```
  19. You can toggle specific features, by default all features (except `compositionAPI`) are enabled, e.g.:
  20. ```js
  21. module.exports = {
  22. presets: [
  23. [
  24. '@vue/babel-preset-jsx',
  25. {
  26. vModel: false,
  27. compositionAPI: true,
  28. },
  29. ],
  30. ],
  31. }
  32. ```
  33. Options are:
  34. - `compositionAPI` - Enables [@vue/babel-sugar-composition-api-inject-h](../babel-sugar-composition-api-inject-h) and [@vue/babel-sugar-composition-api-render-instance](../babel-sugar-composition-api-render-instance), support returning render function in `setup`.
  35. - The default value is `false`;
  36. - When set to `'auto'` (or `true`), it will detect the Vue version in the project. If it's >= 2.7, it will import the composition utilities from `vue`, otherwise from `@vue/composition-api`;
  37. - When set to `'native'` (or `'naruto'`), it will always import the composition utilities from `vue`
  38. - When set to `plugin`, it will always import the composition utilities from `@vue/composition-api`, but it will redirect to `'vue'` itself when the vue version is `2.7.x`
  39. - When set to `vue-demi`, it will always import the composition utilities from `vue-demi`
  40. - When set to an object like `{ importSource: string; }`, it will always import the composition utilities from the importSource you set
  41. - `functional` [@vue/babel-sugar-functional-vue](../babel-sugar-functional-vue/README.md) - Functional components syntactic sugar
  42. - `injectH` [@vue/babel-sugar-inject-h](../babel-sugar-inject-h/README.md) - Automatic `h` injection syntactic sugar
  43. - `vModel` [@vue/babel-sugar-v-model](../babel-sugar-v-model/README.md) - `vModel` syntactic sugar
  44. - `vOn` [@vue/babel-sugar-v-on](../babel-sugar-v-on/README.md) - `vOn` syntactic sugar