Registry / devops / rollup-plugin-local-import

rollup-plugin-local-import

JSON →
library1.2.0jsnpmunverified

A Rollup plugin that transforms local import/export paths in JavaScript/TypeScript bundles. Version 1.2.0 is the latest stable release, as a native addon supporting Windows, macOS, and Linux. It identifies local imports (starting with './' or '../') and applies a user-defined callback to modify the path, leaving external dependencies untouched. Unlike generic string replacement plugins, it uses AST-based detection to avoid false positives on non-import strings.

npm install rollup-plugin-local-import
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-LOCA
R
rollup-plugin-local-import
devopsjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

localImport
import { localImport } from 'rollup-plugin-local-import'
import localImport from 'rollup-plugin-local-import'
The package exports localImport as a named export, not a default. Common mistake is to use default import.
localImport
const { localImport } = require('rollup-plugin-local-import')
const localImport = require('rollup-plugin-local-import')
When using CommonJS, destructure the named export. Direct assignment will be undefined.
Callback type
import type { Callback } from 'rollup-plugin-local-import'
If using TypeScript, you can import the Callback type for type checking.

Basic Rollup config using localImport to add .js extensions to local imports.

// rollup.config.js import { defineConfig } from 'rollup'; import { localImport } from 'rollup-plugin-local-import'; export default defineConfig({ input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ localImport((path) => { // Add .js extension to local imports return `${path}.js`; }) ] });
Debug
Known issues
breakingNative addon may not build on unsupported OS/arch combinations (e.g., FreeBSD, older glibc)
fix
Use a previous version or run on a supported system.
affects: >=1.0.0
gotchaThe plugin only modifies imports/exports that start with './' or '../'. Imports like 'foo' or 'some-package' are left unchanged.
fix
None needed; this is by design.
affects: >=1.0.0
gotchaThe callback is called for every identified local import. If the callback returns the same path unchanged, no modification occurs.
fix
Ensure callback returns a modified string if transformation is intended.
affects: >=1.0.0
gotchaPlugin must be placed before other plugins that also transform import paths to avoid conflicts.
fix
Order plugins carefully in the Rollup config.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: localImport is not a function
Importing default instead of named export
fix
Use import { localImport } from 'rollup-plugin-local-import' instead of import localImport from ...
Error: The plugin 'rollup-plugin-local-import' does not support the current platform ...
Running on an unsupported operating system or architecture
fix
Upgrade node or switch to a supported OS. See documentation for supported platforms.
Cannot find module 'rollup-plugin-local-import'
Package not installed or installed as devDependency
fix
Run 'npm install --save-dev rollup-plugin-local-import' or 'yarn add --dev rollup-plugin-local-import'
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency required as a plugin host
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
2
Resources
rollup-plugin-local-import — npm install rollup-plugin-local-import · libregistry