remove-flow-types-loader

raw JSON →
1.1.0 verified Mon Apr 27 auth: no javascript maintenance

A webpack loader that strips Flow type annotations from JavaScript files during bundling using flow-remove-types. Current stable version is 1.1.0, with low release cadence (last update in 2017). Designed as a lightweight alternative to full Babel transpilation, it operates as a pre-loader to remove Flow types without transforming other syntax. Useful for projects that only need type stripping and want faster builds. Compared to babel-plugin-flow-strip-types, this loader is leaner but lacks plugin ecosystem integration.

error Error: 'remove-flow-types-loader' not found
cause Missing npm install of the loader.
fix
Run 'npm install --save-dev remove-flow-types-loader'
error Module build failed: Error: Failed to read config directory .../node_modules/remove-flow-types-loader
cause Missing peer dependency flow-remove-types.
fix
Run 'npm install --save-dev flow-remove-types'
breaking Loader must be used with enforce: 'pre' in webpack 2+; otherwise it runs after other loaders and may corrupt output.
fix Add 'enforce: "pre"' to the rule object in webpack configuration.
deprecated Webpack 1 preLoaders syntax is deprecated and will cause errors in webpack 2+.
fix Use module.rules with enforce: 'pre' instead of module.preLoaders.
gotcha Options are passed through to flow-remove-types; invalid options may cause silent failures.
fix Refer to flow-remove-types documentation for valid options.
npm install remove-flow-types-loader
yarn add remove-flow-types-loader
pnpm add remove-flow-types-loader

Configures webpack to run remove-flow-types-loader as a pre-loader on all .js/.jsx files inside the src directory, stripping Flow types before other loaders.

// webpack.config.js
const path = require('path');

module.exports = {
  mode: 'development',
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        enforce: 'pre',
        use: ['remove-flow-types-loader'],
        include: path.join(__dirname, 'src')
      }
    ]
  }
};