fast-flow-transform

raw JSON →
0.0.3 verified Mon Apr 27 auth: no javascript

A native Hermes/FFT-based Flow type stripper built on napi-rs, providing programmatic transform, CLI, and bundler adapters for webpack, rspack, rsbuild, Parcel, Vite, Rollup, Rolldown, and esbuild. Current version 0.0.3 (pre-1.0, rapid iteration). Differentiator: uses the battle-tested Hermes parser (same as Metro/React Native) for speed and correctness, supports source map merging, removes empty type-only value imports automatically, and offers a 'preserve' format mode (experimental) that keeps whitespace structure. Compared to alternatives like babel-plugin-flow, it is purpose-built for stripping Flow types without transforming JSX or other syntax.

error Error: Cannot find module 'flow-enums-runtime'
cause Generated code imports flow-enums-runtime when Flow enums are lowered, but it is not installed.
fix
npm install flow-enums-runtime or add to dependencies.
error TypeError: (0 , fast_flow_transform_1.default) is not a function
cause Named import { transform } used instead of default import.
fix
Use import transform from 'fast-flow-transform' or const transform = require('fast-flow-transform').
error SyntaxError: Unexpected token (1:16) - Flow syntax not stripped
cause transform was called without waiting for promise (missing await) or source was not passed correctly.
fix
Ensure transform is awaited: const result = await transform({...}).
error Error: Could not resolve 'fast-flow-transform'
cause Package not installed or mismatched version in package.json.
fix
npm install fast-flow-transform@latest
breaking Source map merge does not preserve upstream sourcesContent or custom metadata fields.
fix If you need full source map chain fidelity, work with babel-plugin-flow or wait for a future release.
gotcha Flow enums lower to flow-enums-runtime package. Generated code imports it at runtime.
fix Install flow-enums-runtime as a production dependency if your project uses Flow enums.
gotcha Empty type-only value imports are removed. This may break code expecting side-effect imports that are actually type-only.
fix If you need to retain an import that appears type-only but has runtime side effects, mark it with a comment or restructure imports.
deprecated reactRuntimeTarget option only affects Flow component lowering. It does not change JSX handling.
fix Use reactRuntimeTarget only when using Flow component syntax with React 18 vs 19. For pure type stripping, omit it.
gotcha Preserve format mode is experimental. Output may differ from input whitespace.
fix Stick to 'compact' or 'pretty' for production. Test preserve mode thoroughly.
npm install fast-flow-transform
yarn add fast-flow-transform
pnpm add fast-flow-transform

Shows basic programmatic usage: importing the default transform function, passing a Flow source string with filename and sourcemap enabled, and logging the stripped output.

import transform from 'fast-flow-transform';

const { code, map } = await transform({
  filename: '/path/to/input.js',
  source: `
    // @flow
    function greet(name: string): string {
      return 'Hello, ' + name;
    }
  `,
  sourcemap: true,
  comments: true,
});

console.log(code);
// Output (stripped): function greet(name) { return 'Hello, ' + name; }
console.log(map); // Source map object