# esbuild-plugin-babel-flow

> esbuild plugin for flow

Latest version **0.0.5** (published 2022-03-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install esbuild-plugin-babel-flow
pnpm add esbuild-plugin-babel-flow
yarn add esbuild-plugin-babel-flow
bun add esbuild-plugin-babel-flow
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2022-03-01 |
| First published | 2022-03-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Henry Ansah |
| Maintainers | henrhie35 |
| Keywords | esbuild, plugin, flow |

## Links

- npm: https://www.npmjs.com/package/esbuild-plugin-babel-flow
- npm.io page: https://npm.io/package/esbuild-plugin-babel-flow

## Dependencies (2)

- [@babel/core](https://npm.io/package/@babel/core.md) ^7.17.5
- [@babel/preset-flow](https://npm.io/package/@babel/preset-flow.md) ^7.16.7

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2022-03-01
- 0.0.4 — 2022-03-01
- 0.0.3 — 2022-03-01
- 0.0.2 — 2022-03-01
- 0.0.1 — 2022-03-01

## README

# esbuild-plugin-babel-flow

Esbuild plugin for transformation of code with [Flow](https://flow.org/) annotations

<br>

Esbuild plugins have limitations to allow developers to hook into every part of the bundling process. This is a deliberate attempt to prevent creating performance bottlenecks during bundling.
Thankfully, Babel, a javascript code transformer allows use to transform code during the code loading event of the esbuild bundling process.
esbuild-plugin-babel-flow under the hood uses babel's transform api to strip javascript code of flow annotations for safe execution in a javascript environment.

## Install

```bash
npm install esbuild-plugin-babel-flow --save-dev
```

<br>

## Usage

config file
`esbuild.config.js`

```js
esbuild
	.build({
		entryPoints: ['example.flow.js'],
		write: true,
		bundle: true,
		outdir: 'dist',
		plugins: [babelFlowPlugin()],
	})
	.catch(() => process.exit(1));
```

input file
`example.flow.js`

```js
// @flow

function foo(x: ?number): string {
	if (x) {
		return JSON.stringify(x);
	}
	return 'default string';
}

foo(55);
```

bundled output
`dist/example.flow.js`

```js
(() => {
	// example.flow.js
	function foo(x) {
		if (x) {
			return JSON.stringify(x);
		}
		return 'default string';
	}
	foo(55);
})();
```

`package.json`

```json
{
	"type": "module",
	"scripts": {
		"start": "node esbuild.config.js"
	}
}
```

## License

[MIT](https://choosealicense.com/licenses/mit/)

---
_Source: https://npm.io/package/esbuild-plugin-babel-flow · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
