filter-chunk-webpack-plugin

raw JSON →
3.0.0 verified Sat Apr 25 auth: no javascript

A webpack plugin (v3.0.0) that filters and excludes assets from final output before emission, using flexible pattern rules (glob, RegExp, or custom functions). Supports include/exclude modes, debug logging, and pipelined rule processing. Requires Node >=20 and webpack ^5, ships TypeScript types. Differentiated by its rule-based pipeline and support for async filter functions. Releases are stable with irregular cadence.

error TypeError: FilterChunkWebpackPlugin is not a constructor
cause Using named import instead of default import or CJS destructuring incorrectly.
fix
Use 'import FilterChunkWebpackPlugin from ...' (ESM) or 'const FilterChunkWebpackPlugin = require(...)' (CJS).
error Error: Cannot find module 'filter-chunk-webpack-plugin'
cause Package not installed or Node version incompatible (<20).
fix
Run 'npm install filter-chunk-webpack-plugin --save-dev' and ensure Node >=20.
error ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
cause Passing invalid options to the plugin constructor.
fix
Ensure options object has correct keys (mode, rules, debug) and rules follow the Rule schema.
error TypeError: Cannot read properties of undefined (reading 'length')
cause Using an async pattern function without awaiting the plugin's apply method or not returning a boolean.
fix
Pattern functions can be async; ensure they return a boolean or Promise<boolean>.
breaking Version 3.0.0 requires Node >=20 and webpack ^5.0.0.
fix Ensure Node.js >=20 and webpack ^5 are installed.
breaking Version 2.0.0 dropped Node v6 support and upgraded to webpack 4 compat.
fix Update Node to >=8 or migrate to v3+ for Node >=20.
gotcha Rules are processed as a pipeline in exclude mode; order matters. Each rule filters from the remaining assets.
fix Arrange rules in intended order, especially when combining exclude and include patterns across multiple rules.
gotcha In include mode, rules are combined with OR logic (union). Assets matching any rule are kept.
fix Ensure include rules are not contradictory; consider using exclude mode with negative patterns instead.
deprecated No known deprecations; the plugin is stable with minimal updates.
npm install filter-chunk-webpack-plugin
yarn add filter-chunk-webpack-plugin
pnpm add filter-chunk-webpack-plugin

Shows basic setup: import the plugin and add an instance to webpack plugins config to exclude .map files from output.

import FilterChunkWebpackPlugin from 'filter-chunk-webpack-plugin';

export default {
  // ... webpack config
  plugins: [
    new FilterChunkWebpackPlugin({
      rules: [
        {
          patterns: '*.map', // remove all .map files
        },
      ],
    }),
  ],
};