Registry / http-networking / rollup-plugin-import-manager

rollup-plugin-import-manager

JSON →
library0.6.4jsnpmunverified

A Rollup plugin for programmatically manipulating import statements in ES6, CommonJS, and dynamic imports. Version 0.6.4 is the latest stable release, with weekly updates. Key features include adding, removing, renaming, and modifying imports, members, and modules. Supports regex selection, cut-and-paste, and debug output. Differentiates from other import plugins by supporting all three module systems and offering granular control via units and actions.

npm install rollup-plugin-import-manager
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-IMPO
R
rollup-plugin-import-manager
http-networkingjavascriptv0.6.4
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.

importManager
✓ import importManager from 'rollup-plugin-import-manager'
✗ const importManager = require('rollup-plugin-import-manager')
Default export; ESM-only since v0.6.0
importManager
✓ import { importManager } from 'rollup-plugin-import-manager'
✗ import importManager from 'rollup-plugin-import-manager'
Named export also available, but default is recommended
Unit
✓ import type { Unit } from 'rollup-plugin-import-manager'
✗ import { Unit } from 'rollup-plugin-import-manager'
Unit is a TypeScript type, use type import

Demonstrates removing an import from './old-module' and adding a new import from './new-module' after './existing-module'.

import importManager from 'rollup-plugin-import-manager'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ importManager({ units: [ { module: './old-module', actions: [ { remove: true } ] }, { createModule: './new-module', insert: { after: './existing-module' }, actions: [ { add: { name: 'newExport' } } ] } ] }) ] };
Debug
Known issues
breakingIn v0.6.0, the plugin changed from CJS to ESM-only. Node <12 or projects using require() will break.
fix
Update to Node >=12 and use ESM imports (import statement).
affects: >=0.6.0
deprecatedThe 'shorthand' action for removing imports is deprecated since v0.5.0; use 'remove: true' in actions array instead.
fix
Replace shorthand remove with { remove: true } inside actions.
affects: >=0.5.0 <0.6.0
gotchaWhen using 'add' action, the member is added even if it already exists, potentially causing duplicate imports.
fix
Check for existing members before adding, or use 'rename' to modify an existing member.
affects: >=0.4.0
gotchaDynamic imports are parsed as strings; the module path must be exactly as written in code, including quotes.
fix
Ensure module strings match source exactly (e.g., 'import('./foo')' needs module: './foo').
affects: all
breakingIn v0.5.0, the 'modType' option required different values; 'es6' changed to 'esm'.
fix
Use 'esm' for ES6 imports instead of 'es6'.
affects: >=0.5.0
Errors
Common errors & fixes
Error: Plugin could not be resolved. Ensure rollup-plugin-import-manager is installed.
Missing package or wrong version (CJS/ESM mismatch).
fix
Install via npm: npm install rollup-plugin-import-manager --save-dev, and use ESM import.
TypeError: importManager is not a function
Using named import instead of default import.
fix
Use default import: import importManager from 'rollup-plugin-import-manager'
Error: Cannot find module 'magic-string'
Missing peer dependency magic-string.
fix
npm install magic-string --save-dev
Upgrade
Version history
0.6.4latest on npm
Audit
Dependencies
rolluprequiredPeer dependency for Rollup plugin interface
magic-stringrequiredUsed for source code transformations with source maps
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
rollup-plugin-import-manager — npm install rollup-plugin-import-manager · libregistry