Registry / web-framework / vite-plugin-flow

vite-plugin-flow

JSON →
library0.2.1jsnpmunverified

Vite plugin that adds Flow type-stripping support using the Flow parser. Current stable version is 0.2.1, released as a stable build. This plugin integrates with Vite's build pipeline to strip Flow type annotations from .js/.jsx files, allowing Vite to handle Flow-typed code without a separate Babel step. Key differentiators: lightweight (uses the official flow-remove-types package), configurable filtering, optional all-files mode, and pretty-printing. Developed by Eazymov and MIT licensed.

npm install vite-plugin-flow
INSTALL
IMPORT
SIG · VITE-PLUGIN-FLOW
V
vite-plugin-flow
web-frameworkjavascriptv0.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

vitePluginFlow
import vitePluginFlow from 'vite-plugin-flow'
const vitePluginFlow = require('vite-plugin-flow')
Default ESM import; CommonJS require() fails because package is ESM-only.
Options
import type { Options } from 'vite-plugin-flow'
Options type is exported; use import type for TypeScript.
vitePluginFlow (default export)
import vitePluginFlow from 'vite-plugin-flow'
import { vitePluginFlow } from 'vite-plugin-flow'
Default export, not named. Named import will be undefined.

Shows how to configure the plugin with all optional settings explicitly set to defaults in a Vite config file.

// vite.config.js import { defineConfig } from 'vite'; import vitePluginFlow from 'vite-plugin-flow'; export default defineConfig({ plugins: [ vitePluginFlow({ all: false, pretty: false, ignoreUninitializedFields: false }) ] });
Debug
Known issues
gotchaPlugin only works with Vite 2+ (ESM-based). It does not support Vite 1.x.
fix
Use Vite 2 or higher.
affects: >=0.1.0
gotchaFile .jsx? filtering by default; if using .mjs or .cjs files, you must provide a custom filter regex.
fix
Set filter option like /\.[mc]?jsx?$/ to include .mjs/.cjs.
affects: >=0.1.0
gotchaThe 'all' option bypasses @flow pragma; use with caution as it will attempt to strip types from all JS files regardless of pragma.
fix
Only enable 'all' if all your JS files are Flow-typed or you want to be aggressive.
affects: >=0.1.0
gotchaWhen using 'pretty: true', the output may change line lengths, which could break source maps if not properly configured.
fix
Enable source maps in Vite (build.sourcemap: true) and test thoroughly.
affects: >=0.1.0
gotchaThe 'ignoreUninitializedFields' option is non-standard; it removes uninitialized class fields like 'foo;' or 'foo: string;' which is not spec-compliant. Prefer using 'declare' for type-only fields.
fix
Use 'declare foo: string;' instead of 'foo: string;' for type-only fields to avoid needing this option.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-flow'
Missing dependency or wrong module resolution due to ESM-only package.
fix
Run 'npm install vite-plugin-flow --save-dev' and ensure project is using ESM (type: module in package.json or .mjs file).
require() of ES Module ... not supported
Using CommonJS require() to import an ES module.
fix
Change to import statement: import vitePluginFlow from 'vite-plugin-flow'
TypeError: vitePluginFlow is not a function
Using named import { vitePluginFlow } instead of default import.
fix
Use import vitePluginFlow from 'vite-plugin-flow' (no braces).
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
flow-remove-typesrequiredCore dependency for stripping Flow type annotations from JavaScript files.
viterequiredPeer dependency; required as the plugin runs in the Vite environment.
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
vite-plugin-flow — npm install vite-plugin-flow · libregistry