Registry /
devops / babel-plugin-filter-imports
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
String (import name)
✓ import { warn } from 'debugging-tools';
✗ const warn = require('debugging-tools').warn;
This plugin operates on ESM import statements; it does not affect CommonJS require() calls.
default import
✓ import log from 'debugging-tools';
✗ import { default } from 'debugging-tools';
Use 'default' in the plugin config to remove the default import.
namespace import
✓ import * as utils from 'debugging-tools';
✗ import { * } from 'debugging-tools';
Use '*' in the plugin config to remove a namespace import (star import).
plugin configuration
✓ ["filter-imports", { imports: { "debugging-tools": ["warn"] } }]
✗ ["filter-imports", { "debugging-tools": ["warn"] }]
Breaking change in v1.x: options must be nested under imports key. Old direct format no longer works.
Demonstrates configuration with multiple imports, keepImports option, and resulting code transformation.
// Install plugin
// npm install --save-dev babel-plugin-filter-imports
// .babelrc or babel.config.js
{
"plugins": [
["filter-imports", {
"imports": {
"debugging-tools": ["warn", "log"],
"another-module": ["default"]
},
"keepImports": false
}]
]
}
// Input source code
import { warn, log } from 'debugging-tools';
import defaultFunc from 'another-module';
function example() {
warn('warning');
log('info');
defaultFunc();
}
// Transformed output (keepImports: false)
function example() {
;
;
;
}
// With keepImports: true, import statements remain but references are removed
function example() {
;
;
;
}
Errors
Common errors & fixes
Error: [BABEL] unknown: Cannot find module 'babel-plugin-filter-imports'
Plugin not installed or not in node_modules.
fixRun 'npm install --save-dev babel-plugin-filter-imports'
Error: Plugin configuration must be an object with an 'imports' key (since v1.x)
Using the old flat configuration format without imports wrapper.
fixChange the plugin config to: ['filter-imports', { imports: { 'module': ['import'] } }] TypeError: Cannot read property 'filter' of undefined (when using namespace import)
Namespace import '*' not properly configured in imports object.
fixEnsure options.imports['module'] includes '*' to remove namespace imports.
Input source code still contains removed imports (keepImports default behavior)
Default keepImports is true, so import declarations remain even if references are removed.
fixSet keepImports: false to remove import declarations as well.
Audit
Dependencies
No dependency data recorded yet.