{"id":22180,"library":"rollup-plugin-preserve-shebangs","title":"rollup-plugin-preserve-shebangs","description":"Rollup plugin that preserves shebang lines (e.g., #!/usr/bin/env node) in bundled output files. Version 0.2.0, last released in 2023. It solves Rollup's inability to parse shebangs by stripping them before compilation and re-adding them to the final output. A lightweight alternative to manual workarounds or community forks. Supports Rollup 2+ and 3+ via peer dependency. Ships TypeScript definitions. No active development, but stable for its niche use case.","status":"maintenance","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/elado/rollup-plugin-preserve-shebangs","tags":["javascript","typescript"],"install":[{"cmd":"npm install rollup-plugin-preserve-shebangs","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-preserve-shebangs","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-preserve-shebangs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin API","package":"rollup","optional":false}],"imports":[{"note":"Named export. ESM or CJS both work.","wrong":"const { default: preserveShebangs } = require('rollup-plugin-preserve-shebangs')","symbol":"preserveShebangs","correct":"import { preserveShebangs } from 'rollup-plugin-preserve-shebangs'"},{"note":"Default export is also available for convenience.","wrong":"const preserveShebangs = require('rollup-plugin-preserve-shebangs')","symbol":"default import","correct":"import preserveShebangs from 'rollup-plugin-preserve-shebangs'"},{"note":"TypeScript types are included, but not exported explicitly. Use the plugin's function type inference.","wrong":"","symbol":"type","correct":"import type { RollupPreserveShebangsOptions } from 'rollup-plugin-preserve-shebangs'"}],"quickstart":{"code":"// rollup.config.js\nimport { preserveShebangs } from 'rollup-plugin-preserve-shebangs';\n\nexport default {\n  input: 'src/cli.js',\n  output: { file: 'dist/cli.js', format: 'cjs' },\n  plugins: [preserveShebangs()]\n};","lang":"javascript","description":"Example Rollup config using preserveShebangs plugin to handle shebang in CLI entry point."},"warnings":[{"fix":"Move preserveShebangs() to the beginning of the plugins list.","message":"Plugin must be the first plugin in the plugins array to strip shebang before other transformations.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Remove BOM from input files or use a BOM-stripping plugin first.","message":"Only works with shebang as the very first line of the file (byte order mark (BOM) before shebang may cause issues).","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Test with Rollup 4; if broken, consider manually handling shebang via banner option or custom plugin.","message":"Plugin is unmaintained since 2023; no updates for Rollup 4 compatibility verified.","severity":"deprecated","affected_versions":"<=0.2.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add preserveShebangs() plugin to rollup config.","cause":"Rollup cannot parse shebang line as JavaScript.","error":"Error: Unexpected character '#'"},{"fix":"Run npm install rollup-plugin-preserve-shebangs --save-dev and check import statement.","cause":"Plugin not installed or incorrect import path.","error":"Module not found: Error: Can't resolve 'rollup-plugin-preserve-shebangs'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}