A webpack plugin allowing to call `flow` type checker.
Latest commit b8683eb Jan 16, 2017 happylynx .travis.yml added



A webpack plugin allowing to call Flow type checker during each webpack compilation.

Key features

  • It doesn't require flow to be in $PATH.
  • No dependencies. Plugin can reuse project's flow-bin installation.
  • It can make webpack to exit with non-zero return code, if flow validation fails.
  • It works per project, not per file.


npm install --save-dev flow-webpack-plugin

Webpack configuration file:

const FlowWebpackPlugin = require('flow-webpack-plugin')

module.exports = {
    plugins: [
        new FlowWebpackPlugin(),
        // or with configuration:
        // new FlowWebpackPlugin({
        //     failOnError: false,
        //     failOnErrorWatch: false,
        //     printFlowOutput: true,
        //     flowPath: require.main.require('flow-bin'),
        //     flowArgs: [],
        //     verbose: false
        // }),
        // ...
    // ...


Constructor of FlowWebpackPlugin accepts optional configuration object of following properties:

  • failOnError: boolean, default: false
    Webpack exits with non-zero error code if flow typechecking fails.
  • failOnErrorWatch: boolean, default: false
    Webpack in watch mode exits with non-zero error code if flow typechecking fails.
  • printFlowOutput: boolean, default: true
    true ~ Output of flow is redirected to stdout/stderr of webpack, false output of flow is discarded.
  • flowPath: string, default: require('flow-bin') if flow-bin package is installed. Otherwise the parameter is required.
    Path to flow executable. It may be both absolute, relative to the 'cwd' of webpack process or just name of an executable on the PATH.
  • flowArgs: Array<string>, default: []
    Flow command line arguments. See flow cli documentation.
  • verbose: boolean, default: false
    It enables plugin logging for debug purposes.

Type annotations strip

This plugin performs type validation of the code. To remove the Flow type annotations and create pure Javascript code babel-plugin-transform-flow-strip-types can be used.


Valid codebase:
Valid codebase

Flow validation error:
Flow validation error