rollup-plugin-strip-banner

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

Rollup plugin to remove banner comments (e.g., license headers) from module files before bundling. Current stable version is 3.1.0, released with support for Rollup 4.x. Released irregularly, with major version bumps aligning with Rollup peer dependency updates. Key differentiator: lightweight, focused solely on banner stripping without additional transforms. Alternatives like rollup-plugin-terser or manual regex require more configuration. Ships TypeScript types.

error Error: Cannot find module 'rollup-plugin-strip-banner'
cause Deprecation: the package is not actively maintained and may have been removed from npm or not installed.
fix
npm install rollup-plugin-strip-banner --save-dev
error TypeError: stripBanner is not a function
cause Using named import 'stripBanner' instead of default import.
fix
Use import stripBanner from 'rollup-plugin-strip-banner' (default import) instead of import { stripBanner } from 'rollup-plugin-strip-banner' (named import).
error The 'include' and 'exclude' options are not working as expected
cause Misunderstanding of minimatch patterns or order of precedence.
fix
Ensure include/exclude follow minimatch glob patterns; exclude overrides include. Use absolute or relative paths correctly.
deprecated rollup-plugin-strip-banner is deprecated; consider using a custom Rollup transform instead.
fix Use rollup-plugin-strip-banner at your own risk or implement a simple plugin that removes banner comments via regex or AST.
breaking Version 3.0.0 drops support for Node <14.
fix Upgrade Node to version 14 or later.
breaking Version 2.0.0 drops support for Node <10 and Rollup <2.
fix Use Rollup >=2 and Node >=10.
gotcha The plugin may incorrectly remove banners that are not at the very top of the file (e.g., leading comments after shebang).
fix Ensure banners are at the top of the module before you trust stripping; consider verifying output.
breaking Version 1.0.0 includes a fix for sourcemap generation; previous versions may produce faulty sourcemaps.
fix Upgrade to >=1.0.0 to avoid sourcemap issues.
npm install rollup-plugin-strip-banner
yarn add rollup-plugin-strip-banner
pnpm add rollup-plugin-strip-banner

Configures rollup-plugin-strip-banner in a Rollup config file with include/exclude patterns.

// rollup.config.js
import stripBanner from 'rollup-plugin-strip-banner';
import { defineConfig } from 'rollup';

export default defineConfig({
  input: 'src/index.js',
  output: {
    file: 'dist/index.js',
    format: 'esm'
  },
  plugins: [
    stripBanner({
      include: '**/*.js',
      exclude: 'node_modules/**'
    })
  ]
});