Registry / type-stubs / rollup-plugin-flow

rollup-plugin-flow

JSON →
library1.1.1jsnpmunverified

A Rollup plugin to strip Flow type annotations from JavaScript/Flow files before bundling, using flow-remove-types under the hood. Current stable version is 1.1.1, with minimal maintenance cadence. It transforms files containing @flow comments by default, with an option to process all files. Provides a 'pretty' mode that removes types without adding whitespace. Differentiators: lightweight and fast compared to full Flow transformation; does not require Flow itself to run; integrates seamlessly with Rollup's build pipeline.

npm install rollup-plugin-flow
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-FLOW
R
rollup-plugin-flow
type-stubsjavascriptv1.1.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

default
✓ import flow from 'rollup-plugin-flow'
✗ const flow = require('rollup-plugin-flow');
CommonJS require still works in older versions; this is the default export
flow function
✓ import flow from 'rollup-plugin-flow'; plugins: [ flow({ all: true }) ]
✗ import { flow } from 'rollup-plugin-flow'
The package exports a single function as default export, not a named export. Named import will be undefined.
usage in rollup config
✓ import flow from 'rollup-plugin-flow'; export default { input: 'src/index.js', plugins: [flow()] }
✗ plugins: [ { transform: ... } ]
Must call the imported function to create the plugin instance.

Basic usage: import the default export, call it with options, pass as plugin to Rollup.

import flow from 'rollup-plugin-flow'; import { rollup } from 'rollup'; const bundle = await rollup({ input: 'src/index.js', plugins: [ flow({ all: true, pretty: false }) ] }); const { output } = await bundle.generate({ format: 'esm' }); console.log(output[0].code);
Debug
Known issues
gotchaFlow transformation is applied before bundling, so it cannot be combined with other transforms that depend on flow annotations.
fix
Ensure this plugin is first in the plugins array if other plugins should see untyped code; else place after Babel if Babel should handle Flow.
affects: >=1.0.0
gotchaThe plugin does not type-check the code; it only removes annotations. For type checking, run Flow separately.
fix
Run flow check as a separate step before bundling.
affects: >=1.0.0
breakingIn version 1.1.0, the default export changed from an object to a function. Old usage `plugins: [flow]` will break; must call `flow()`
fix
Change `plugins: [flow]` to `plugins: [flow()]` or `plugins: [require('rollup-plugin-flow')()]`
affects: >=1.1.0
deprecatedRollup changed its plugin API; the plugin expects a `transform` hook that receives `{code, map}`, not `source`
fix
Update rollup to a version compatible with the plugin's API (rollup <0.50)
affects: >=0.25.0
gotchaWhen using `pretty: true`, source maps are recommended but not generated by default; output may have incorrect line mappings.
fix
Set `sourcemap: true` in rollup config and provide input sourcemap if available.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'flow-remove-types'
flow-remove-types is not installed
fix
npm install flow-remove-types --save-dev
TypeError: flow is not a function
Using an older version of the plugin where default export was an object
fix
Update to version 1.1.1 and call `flow()` instead of just `flow`
The plugin does nothing — no types removed
Files do not contain @flow comment; `all` option not set
fix
Add `@flow` comment to files or set `all: true` in plugin options
Unexpected token ':'
Flow syntax not stripped before bundling; plugin not included or misconfigured
fix
Ensure rollup-plugin-flow is added to plugins array and called correctly
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
rollupoptionalpeer dependency; plugin designed for Rollup >=0.20
flow-remove-typesrequiredruntime dependency to strip Flow type annotations
Agent activity
23 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
rollup-plugin-flow — npm install rollup-plugin-flow · libregistry