# @vue/babel-sugar-functional-vue

> Babel syntactic sugar for functional components

Latest version **1.4.0** (published 2022-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vue/babel-sugar-functional-vue
pnpm add @vue/babel-sugar-functional-vue
yarn add @vue/babel-sugar-functional-vue
bun add @vue/babel-sugar-functional-vue
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2022-08-25 |
| First published | 2018-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1476 |
| Author | Nick Messing |
| Maintainers | nickmessing, soda, yyx990803 |

## Links

- npm: https://www.npmjs.com/package/@vue/babel-sugar-functional-vue
- Repository: https://github.com/vuejs/jsx.git#master
- Homepage: https://github.com/vuejs/jsx/tree/master#readme
- Issues: https://github.com/vuejs/jsx/issues
- npm.io page: https://npm.io/package/@vue/babel-sugar-functional-vue

## Dependencies (1)

- [@babel/plugin-syntax-jsx](https://npm.io/package/@babel/plugin-syntax-jsx.md) ^7.2.0

## Recent versions

- 1.4.0 (latest) — 2022-08-25
- 1.2.2 — 2020-10-17
- 1.2.1 — 2020-10-16
- 1.2.0 — 2020-10-16
- 1.1.2 — 2019-11-09
- 1.0.0 — 2019-05-08
- 1.0.0-beta.3 — 2019-03-22
- 1.0.0-beta.2 — 2019-01-11
- 1.0.0-beta.1 — 2018-12-25
- 0.1.0 — 2018-08-27

## README

## @vue/babel-sugar-functional-vue

Syntactic sugar for functional components.

### Babel Compatibility Notes

- 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)

### Usage

Install the dependencies:

```sh
# for yarn:
yarn add @vue/babel-sugar-functional-vue
# for npm:
npm install @vue/babel-sugar-functional-vue --save
```

In your `.babelrc`:

```json
{
  "plugins": ["@vue/babel-sugar-functional-vue"]
}
```

However it is recommended to use the [configurable preset](../babel-preset-jsx/README.md) instead.

### Details

This plugin transpiles arrow functions that return JSX into functional components but only if it's an uppercase variable declaration or default export:

```js
// Original:
export const A = ({ props, listeners }) => <div onClick={listeners.click}>{props.msg}</div>
export const b = ({ props, listeners }) => <div onClick={listeners.click}>{props.msg}</div>
export default ({ props, listeners }) => <div onClick={listeners.click}>{props.msg}</div>

// Result:
export const A = {
  functional: true,
  render: (h, {
    props,
    listeners
  }) => <div onClick={listeners.click}>{props.msg}</div>
}
export const b = ({ props, listeners }) => <div onClick={listeners.click}>{props.msg}</div>
export default {
  functional: true,
  render: (h, {
    props,
    listeners
  }) => <div onClick={listeners.click}>{props.msg}</div>
}
```

---
_Source: https://npm.io/package/@vue/babel-sugar-functional-vue · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
