{"id":22118,"library":"rollup-plugin-local-import","title":"rollup-plugin-local-import","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/AriPerkkio/rollup-plugin-local-import","tags":["javascript","typescript"],"install":[{"cmd":"npm install rollup-plugin-local-import","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-local-import","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-local-import","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required as a plugin host","package":"rollup","optional":false}],"imports":[{"note":"The package exports localImport as a named export, not a default. Common mistake is to use default import.","wrong":"import localImport from 'rollup-plugin-local-import'","symbol":"localImport","correct":"import { localImport } from 'rollup-plugin-local-import'"},{"note":"When using CommonJS, destructure the named export. Direct assignment will be undefined.","wrong":"const localImport = require('rollup-plugin-local-import')","symbol":"localImport","correct":"const { localImport } = require('rollup-plugin-local-import')"},{"note":"If using TypeScript, you can import the Callback type for type checking.","wrong":"","symbol":"Callback type","correct":"import type { Callback } from 'rollup-plugin-local-import'"}],"quickstart":{"code":"// rollup.config.js\nimport { defineConfig } from 'rollup';\nimport { localImport } from 'rollup-plugin-local-import';\n\nexport default defineConfig({\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    localImport((path) => {\n      // Add .js extension to local imports\n      return `${path}.js`;\n    })\n  ]\n});","lang":"typescript","description":"Basic Rollup config using localImport to add .js extensions to local imports."},"warnings":[{"fix":"Use a previous version or run on a supported system.","message":"Native addon may not build on unsupported OS/arch combinations (e.g., FreeBSD, older glibc)","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"None needed; this is by design.","message":"The plugin only modifies imports/exports that start with './' or '../'. Imports like 'foo' or 'some-package' are left unchanged.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure callback returns a modified string if transformation is intended.","message":"The callback is called for every identified local import. If the callback returns the same path unchanged, no modification occurs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Order plugins carefully in the Rollup config.","message":"Plugin must be placed before other plugins that also transform import paths to avoid conflicts.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import { localImport } from 'rollup-plugin-local-import' instead of import localImport from ...","cause":"Importing default instead of named export","error":"TypeError: localImport is not a function"},{"fix":"Upgrade node or switch to a supported OS. See documentation for supported platforms.","cause":"Running on an unsupported operating system or architecture","error":"Error: The plugin 'rollup-plugin-local-import' does not support the current platform ..."},{"fix":"Run 'npm install --save-dev rollup-plugin-local-import' or 'yarn add --dev rollup-plugin-local-import'","cause":"Package not installed or installed as devDependency","error":"Cannot find module 'rollup-plugin-local-import'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}