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.
npm install rollup-plugin-preserve-shebangsVerified import paths — ran on the pinned version, not inferred.
Example Rollup config using preserveShebangs plugin to handle shebang in CLI entry point.
Move preserveShebangs() to the beginning of the plugins list.
Remove BOM from input files or use a BOM-stripping plugin first.
Test with Rollup 4; if broken, consider manually handling shebang via banner option or custom plugin.
Add preserveShebangs() plugin to rollup config.
Run npm install rollup-plugin-preserve-shebangs --save-dev and check import statement.