Registry / web-framework / rollup-plugin-ignore-import

rollup-plugin-ignore-import

JSON →
library1.3.2jsnpmunverified

Rollup plugin to ignore imports based on file extensions (e.g., .css, .scss) during bundling, replacing them with a configurable stub. Version 1.3.2 is the latest stable release. The plugin uses rollup-pluginutils for filtering and supports both extension and include patterns. It's useful in test environments or when you want to exclude static assets from the bundle without ejecting. Unlike rollup-plugin-string or inject, this plugin fully removes the import and substitutes a default export.

npm install rollup-plugin-ignore-import
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-IGNO
R
rollup-plugin-ignore-import
web-frameworkjavascriptv1.3.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ignoreImport
✓ import ignoreImport from 'rollup-plugin-ignore-import'
✗ import { ignoreImport } from 'rollup-plugin-ignore-import'
Default export; no named export exists. Using named import will work in TypeScript but is unconventional.
ignoreImport
✓ const ignoreImport = require('rollup-plugin-ignore-import')
✗ const { ignoreImport } = require('rollup-plugin-ignore-import')
CJS require returns the plugin function directly; destructuring fails.
Plugin (type)
✓ import type { Plugin } from 'rollup'
✗ import type { Plugin } from 'rollup-plugin-ignore-import'
This package does not export its own types; the return type is Rollup's Plugin. Use `import ignoreImport from '...'` and infer the type.

Shows how to configure rollup-plugin-ignore-import to replace .css and .scss imports with a configurable stub, while other plugins like resolve still work.

// rollup.config.js import ignoreImport from 'rollup-plugin-ignore-import'; import resolve from '@rollup/plugin-node-resolve'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ resolve(), ignoreImport({ extensions: ['.css', '.scss'], body: 'export default "ignored";' }) ] }; // Input src/index.js import './style.css'; console.log('Hello'); // Output dist/index.js will have no import for style.css; the import is replaced with `const style = "ignored";` (or similar).
Debug
Known issues
breakingThe package requires rollup-pluginutils as a peer dependency, which may not be automatically installed with newer Rollup versions. This can cause 'Cannot find module 'rollup-pluginutils'' errors.
fix
Install rollup-pluginutils explicitly: npm install rollup-pluginutils --save-dev. Or use rollup-plugin-ignore-import@2.0.0 (if available) that may have dropped this dependency.
affects: >=1.0.0 <2.0.0
gotchaThe plugin replaces ignored imports with a default export of `undefined` by default. If you rely on the import to have a specific shape (e.g., CSS modules), the replacement may cause runtime errors.
fix
Specify a `body` option that matches what your code expects, e.g., `body: 'export default {};'` for CSS modules.
affects: >=0.1.0
deprecatedThe `include` and `exclude` options accept glob patterns but are handled by rollup-pluginutils's createFilter, which does not support negative patterns (like `!**/*.css`). Use `extensions` instead for simpler cases.
fix
Use `extensions: ['.css']` instead of `include: ['**/*.css']`. If you need exclude, consider a different plugin like rollup-plugin-filter.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-pluginutils'
rollup-pluginutils is listed as a peer dependency but not installed automatically by npm/yarn in some configurations.
fix
Run `npm install rollup-pluginutils --save-dev` or add it to devDependencies manually.
ReferenceError: exports is not defined
Using CJS require in an ESM context (e.g., "type": "module" in package.json).
fix
Use `import ignoreImport from 'rollup-plugin-ignore-import'` instead of `require`.
TypeError: ignoreImport is not a function
Destructuring the default export incorrectly.
fix
Change `import { ignoreImport } from 'rollup-plugin-ignore-import'` to `import ignoreImport from 'rollup-plugin-ignore-import'`.
Upgrade
Version history
1.3.2latest on npm
Audit
Dependencies
rolluprequiredPeer dependency: also a Rollup plugin works only with Rollup >=0.62.0
rollup-pluginutilsrequiredPeer dependency: used for filtering (createFilter) in versions before Rollup 5, but the package still lists it as peer
Agent activity
6 hits · last 30 days
node
6
Resources
rollup-plugin-ignore-import — npm install rollup-plugin-ignore-import · libregistry