Registry / devops / esbuild-plugin-babel-flow

esbuild-plugin-babel-flow

JSON →
library0.0.5jsnpmunverified

An esbuild plugin for stripping Flow type annotations from JavaScript files using Babel under the hood. Current version is 0.0.5, released as an early-stage package. It integrates into the esbuild plugin system via the 'onLoad' event, transforming code with Babel's transform API to remove Flow types for safe execution. Key differentiators: it bridges esbuild's lack of native Flow support by leveraging Babel's flow-strip-types preset. Alternative plugins exist (e.g., esbuild-plugin-flow), but this one explicitly uses Babel for compatibility. Note that peer dependency esbuild ^0.14.23 is required.

npm install esbuild-plugin-babel-flow
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-BAB
E
esbuild-plugin-babel-flow
devopsjavascriptv0.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

babelFlowPlugin
✓ import { babelFlowPlugin } from 'esbuild-plugin-babel-flow'
✗ import babelFlowPlugin from 'esbuild-plugin-babel-flow'
The package uses a named export, not a default export. CommonJS require works: const { babelFlowPlugin } = require('esbuild-plugin-babel-flow')
default
✓ There is no default export.
✗ import plugin from 'esbuild-plugin-babel-flow'
Attempting a default import will result in undefined.
babelFlowPlugin (type)
✓ import type { babelFlowPlugin } from 'esbuild-plugin-babel-flow'
✗ import { babelFlowPlugin } from 'esbuild-plugin-babel-flow' (if only type)
TypeScript type import is safe; the package does not ship its own types, but you can declare or use Babel types.

Demonstrates setting up esbuild with the Flow-stripping plugin, bundling a file with Flow type annotations.

import { build } from 'esbuild'; import { babelFlowPlugin } from 'esbuild-plugin-babel-flow'; build({ entryPoints: ['example.flow.js'], bundle: true, outdir: 'dist', plugins: [babelFlowPlugin()], }).catch(() => process.exit(1)); // Ensure package.json has "type": "module" or use .mjs extension
Debug
Known issues
gotchaPlugin does not perform type checking; it only strips types. Use Flow separately for type validation.
fix
Run flow check before or after bundling.
affects: >=0.0.0
gotchaesbuild peer dependency must be ^0.14.23. Using other versions may cause incompatibility.
fix
Ensure esbuild version meets requirement.
affects: >=0.0.0
gotchaThe plugin applies Babel transformation to all loaded JS files, which may slow down builds for large codebases.
fix
Use esbuild's filter option to only apply plugin to files containing Flow annotations.
affects: >=0.0.0
breakingNo breaking changes documented as package is very early (v0.0.5). API subject to change.
fix
Pin version and monitor releases.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-plugin-babel-flow'
Package not installed or not in node_modules.
fix
Run npm install esbuild-plugin-babel-flow --save-dev
TypeError: esbuild.build is not a function
Incorrect esbuild import; common mistake importing default from esbuild.
fix
Use import { build } from 'esbuild'
ReferenceError: require is not defined in ES module scope
Using CommonJS require in an ES module package.json with "type": "module".
fix
Use import { babelFlowPlugin } from 'esbuild-plugin-babel-flow'
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency; plugin runs in esbuild's build process.
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-babel-flow — npm install esbuild-plugin-babel-flow · libregistry