esbuild-plugin-flow
raw JSON → 0.3.2 verified Fri May 01 auth: no javascript
Esbuild plugin for stripping Flow type annotations using flow-remove-types. Current version 0.3.2 (latest). Installation requires direct GitHub URL. Designed for custom build scripts, not CLI. Key differentiator: integrates Flow type stripping into esbuild bundling. Alternatives like @babel/preset-flow require Babel; this plugin is lightweight. Entry point files are not processed (known limitation). Options include regex for file matching and optional force flag to strip even without @flow pragma.
Common errors
error Cannot find module 'esbuild-plugin-flow' ↓
cause Package installed from GitHub URL, but Node.js module resolution may not find it if global symlinks are missing.
fix
Ensure you ran 'npm install https://github.com/dalcib/esbuild-plugin-flow' from the project root.
error TypeError: flow is not a function ↓
cause Using import instead of require, or not invoking the default export correctly.
fix
Use const flow = require('esbuild-plugin-flow'); flow(/regex/);
error Error: The plugin must be a function or an object with a 'name' and 'setup' function. ↓
cause Passing a string instead of a RegExp to the flow function, causing esbuild to receive an invalid plugin object.
fix
Ensure the argument to flow() is a RegExp, e.g., /\.flow\.jsx?$/
Warnings
breaking Entry point files are not processed by this plugin due to esbuild limitations; Flow types in entry point will not be stripped. ↓
fix Move entry point content into a non-entry module or use a separate build step for the entry file.
gotcha Installation requires GitHub URL, not npm registry. 'npm i --dev esbuild-plugin-flow' will fail. ↓
fix Install via: npm i --dev https://github.com/dalcib/esbuild-plugin-flow
gotcha The regex argument must be a RegExp object; passing a string will cause unexpected behavior. ↓
fix Pass a RegExp literal, e.g., /\.flow\.jsx?$/
gotcha Plugin does not support ESM; using import syntax will fail. ↓
fix Use require('esbuild-plugin-flow') instead.
Install
npm install esbuild-plugin-flow yarn add esbuild-plugin-flow pnpm add esbuild-plugin-flow Imports
- esbuild-plugin-flow wrong
import flow from 'esbuild-plugin-flow'correctconst flow = require('esbuild-plugin-flow') - default
const flow = require('esbuild-plugin-flow') - flow (function) wrong
flow('regex')correctflow(/regex/, false)
Quickstart
const esbuild = require('esbuild');
const flow = require('esbuild-plugin-flow');
esbuild.build({
entryPoints: ['index.js'],
outfile: 'dist/bundle.js',
bundle: true,
plugins: [flow(/\.flow\.jsx?$/)]
}).catch(() => process.exit(1));