npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flow-webpack-plugin

v1.2.0

Published

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

Downloads

6,464

Readme

flow-webpack-plugin

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

npm npm npm David

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.

Installation

Run in you project directory:

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

or using yarn:

yarn add flow-webpack-plugin flow-bin --dev

Add to your webpack configuration file webpack.config.js:

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

module.exports = {
    plugins: [
        new FlowWebpackPlugin(),
        // ...
    ],
    // ...
}

Note: flow-bin package is not a hard dependency. If flow is already installed on your system, it can be reused through flowPath option.

Screenshots

Valid codebase:
Valid codebase

Flow validation error:
Flow validation error

Configuration

Constructor of FlowWebpackPlugin accepts optional configuration object of following properties:

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

new FlowWebpackPlugin({
    failOnError: false,
    failOnErrorWatch: false,
    reportingSeverity: 'error',
    printFlowOutput: true,
    flowPath: require.main.require('flow-bin'),
    flowArgs: ['--color=always'],
    verbose: false,
    callback: (result) => {}
})

| option | type | default value | description | | --- | --- | --- | --- | | failOnError | boolean | false | Webpack exits with non-zero error code if flow typechecking fails. | | failOnErrorWatch | boolean | false | Webpack in watch mode exits with non-zero error code if flow typechecking fails. | | reportingSeverity | 'warning' | 'error' | 'error' | Webpack severity level of reported flow type problems. When using webpack-dev-server, page reload is blocked in case of webpack error. warning can be used to enable page reloads in case of flow errors when using webpack-dev-server. | | printFlowOutput | boolean | true | true ~ Output of flow is printed at the end of webpack compilation in case of error, false ~ output of flow is discarded. | | flowPath | string | 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> | ['--color=always'] if standard output is directed to a terminal, otherwise [] | Flow command line arguments. See flow cli documentation. | | verbose | boolean | false | It enables plugin logging for debug purposes. | | callback | ({exitCode: number, stdout: string, stderr: string}) => ?Promise<any> | (result) => {} | Custom user function that is called when Flow check finishes and is passed Flow type check result. If function returns a promise, it is called asynchronously. |

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.