Flow Status Webpack Plugin

0.1.8 · abandoned · verified Sun Apr 19

This webpack plugin integrates Flow type checking directly into the Webpack build process. On webpack startup, it automatically starts or restarts a Flow server, and subsequently runs `flow status` after each build. The package is currently at version 0.1.8 and was last published over a year ago, indicating it is no longer actively maintained. It was explicitly marked as "experimental" in its documentation. Key differentiators include its ability to pass custom Flow arguments, control Flow server restarts, specify a custom Flow binary path, and optionally fail the webpack build if Flow type checks produce errors. Given its age and the low version number, it is primarily compatible with older Webpack and Node.js environments and does not follow modern module conventions (e.g., ESM). Developers should be aware of its unmaintained status and consider alternatives for current projects.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic integration of the FlowStatusWebpackPlugin into a webpack configuration. It includes babel for Flow syntax stripping, configures the plugin to fail on Flow errors, and provides success/error callbacks. It highlights the use of `failOnError`, `restartFlow`, and `binaryPath` options.

const path = require('path');
const webpack = require('webpack');
const FlowStatusWebpackPlugin = require('flow-status-webpack-plugin');

module.exports = {
  mode: 'development',
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env', '@babel/preset-flow']
          }
        }
      }
    ]
  },
  plugins: [
    // In modern webpack, new webpack.NoErrorsPlugin() is deprecated/removed.
    // If using an older webpack, uncomment this line:
    // new webpack.NoErrorsPlugin(),
    new FlowStatusWebpackPlugin({
      failOnError: true, // Fail the webpack build if Flow reports errors
      restartFlow: true, // Always restart the Flow server with each build
      binaryPath: path.resolve(__dirname, 'node_modules/.bin/flow'), // Specify local Flow binary
      onSuccess: function(stdout) { console.log('Flow is happy!\n', stdout); },
      onError: function(stdout) { console.error('Flow found errors!\n', stdout); }
    })
  ]
};

// To run:
// 1. Create src/index.js with some Flow code, e.g.:
//    // @flow
//    function add(a: number, b: number): number {
//      return a + b;
//    }
//    const result: string = add(1, 2); // This will cause a Flow error (number assigned to string)
//    console.log(result);
// 2. npm install --save-dev webpack webpack-cli flow-status-webpack-plugin @babel/core babel-loader @babel/preset-env @babel/preset-flow flow-bin
// 3. Initialize Flow: npx flow init
// 4. Run webpack: npx webpack

view raw JSON →