A Rollup plugin that automatically preserves a shebang (#!) line from your entry file in the bundle output. Version 1.0.1 is current stable, with maintenance-level activity. Key differentiator: it handles multi-entry setups and allows overriding the shebang string, unlike alternatives that only work with single entries or require manual configuration. It auto-detects the shebang from the entry file or can be explicitly set via plugin options. Supports Rollup 1+ and Node 14+. Lightweight with no dependencies.
npm install rollup-plugin-preserve-shebangVerified import paths — ran on the pinned version, not inferred.
Shows basic usage: import the default export, call shebang() in Rollup's plugins array to preserve the shebang from the entry file.
Upgrade Rollup to version 1 or higher.
Either ensure the entry file starts with #! or use the `shebang` option to provide one.
Use dynamic import() or ensure your project uses ESM (type: 'module' in package.json).
Use import syntax instead of require, or convert your config to ESM by adding 'type': 'module' in package.json.
Call shebang() function: plugins: [shebang()].
Add #!/usr/bin/env node as first line of entry file, or provide shebang option: shebang({ shebang: '#!/usr/bin/env node' }).No dependency data recorded yet.