{"id":22221,"library":"rollup-plugin-shim","title":"rollup-plugin-shim","description":"A Rollup plugin that replaces module imports with a specified string shim, useful for stripping out dev-time dependencies like 'debug' in production builds. Stable at v1.0.0 since 2017, with minimal releases. Unlike rollup-plugin-alias, this plugin replaces the module content inline with a string rather than pointing to another file, making it ideal for small shims. Best for simple noop replacements; for complex aliasing, use rollup-plugin-alias instead. Active maintenance is low, but the plugin works with Rollup 0.x and 1.x.","status":"maintenance","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/patrickhulce/rollup-plugin-shim","tags":["javascript"],"install":[{"cmd":"npm install rollup-plugin-shim","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-shim","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-shim","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Requires Rollup as a peer dependency to function as a plugin.","package":"rollup","optional":false}],"imports":[{"note":"The package exports a single default function; named import will result in undefined.","wrong":"import { shim } from 'rollup-plugin-shim'","symbol":"default (shim)","correct":"import shim from 'rollup-plugin-shim'"},{"note":"CommonJS require works, but Rollup configs typically use ESM import.","wrong":null,"symbol":"shim (CommonJS)","correct":"const shim = require('rollup-plugin-shim')"},{"note":"Package has no TypeScript definitions; use require style or add a module declaration.","wrong":"import shim from 'rollup-plugin-shim'  // not typed, use require for TS compatibility","symbol":"shim (TypeScript)","correct":"import shim = require('rollup-plugin-shim')"}],"quickstart":{"code":"import shim from 'rollup-plugin-shim';\n\nexport default {\n  input: 'src/main.js',\n  output: { format: 'es' },\n  plugins: [\n    shim({\n      'debug': `export default () => () => undefined`,\n      'fs': `export function writeFileSync() {}`\n    })\n  ]\n};","lang":"javascript","description":"Shows how to configure the plugin to replace 'debug' and 'fs' imports with noop stubs in a Rollup config."},"warnings":[{"fix":"Use distinct keys or handle per-module with custom resolve.","message":"Plugin overwrites imports globally; if two modules use the same import name but expect different behavior, shimming may break one of them.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure shim strings are valid JavaScript/ES module syntax.","message":"Shim values are strings that are evaluated as modules; syntax errors in the shim string will cause build failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Test with your Rollup version; consider using '@rollup/plugin-alias' or newer alternatives.","message":"The plugin may not work with Rollup >=2.0.0 due to API changes; it was developed for Rollup 0.x/1.x.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use full paths or bare specifiers as they appear in import statements.","message":"Keys in the shim object must match the import specifier exactly, including file extensions if used in the import.","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":"Correct the shim string to be valid ES module syntax.","cause":"Shim string contains syntax errors or invalid module format.","error":"Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)"},{"fix":"Use default import: `import shim from 'rollup-plugin-shim'`.","cause":"Importing the plugin incorrectly (e.g., using named import when default is needed).","error":"TypeError: shim is not a function"},{"fix":"Run `npm install rollup-plugin-shim --save-dev` or `yarn add -D rollup-plugin-shim`.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'rollup-plugin-shim'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}