rollup-plugin-blacklist

raw JSON →
1.0.1 verified Mon Apr 27 auth: no javascript

Rollup plugin that excludes files matching specified patterns from being bundled. Version 1.0.1 (latest) has no further releases. Inspired by blacklistify for Browserify, it provides a simple filtering mechanism to prevent accidental inclusion of modules (e.g., worker code in main bundle). Typically used early in plugin chain before resolvers like @rollup/plugin-node-resolve.

error Cannot find module 'rollup-plugin-blacklist'
cause Package not installed or incorrect import path (e.g., using named import instead of default).
fix
Install with npm install --save-dev rollup-plugin-blacklist and use default import: import blacklist from 'rollup-plugin-blacklist'.
gotcha Must be placed before other resolution plugins like @rollup/plugin-node-resolve to block modules at the import name level.
fix Ensure blacklist() is the first plugin in the plugins array.
gotcha Patterns are regex objects, not strings. Using strings will be silently ignored.
fix Pass regex patterns: blacklist([/pattern/]).
gotcha Does not support dynamic imports or code splitting — only static import statements are blocked.
fix Alternative: use a more comprehensive plugin like @rollup/plugin-inject or manual tree-shaking.
npm install rollup-plugin-blacklist
yarn add rollup-plugin-blacklist
pnpm add rollup-plugin-blacklist

Shows basic usage: import default export and pass array of regex patterns to exclude matching modules.

// rollup.config.js
import blacklist from 'rollup-plugin-blacklist';

export default {
  input: 'src/index.js',
  output: [{ file: 'dist/bundle.js', format: 'esm' }],
  plugins: [
    blacklist([/worker/]),
    // Resolver plugins must come after blacklist
  ]
};