A Rollup plugin (v0.1.0, last updated Dec 2024) for preserving or inserting shebang (#!) lines and setting executable permissions on output files. Supports Rollup 2, 3, and 4 via peer dependency. Configurable patterns, shebang string, separator, insert/preserve behavior, and file mode. Unlike simpler shebang plugins, this one allows separate control over preservation and insertion, plus executable mode setting. Ships TypeScript types and supports both ESM and CJS. Requires Node 14+, actively maintained with a history of dependency upgrades and Rollup version support.
npm install rollup-plugin-shebang-binVerified import paths — ran on the pinned version, not inferred.
Minimal rollup config using the plugin with all options explicitly set.
Use import syntax instead of require(). If using CommonJS, migrate to ESM or use dynamic import().
Upgrade to Rollup 3 or 4 if possible, as older versions may drop support.
Set preserve: true or insert: true to avoid unintended shebang removal.
Check your umask (run 'umask' in shell) and adjust mode accordingly, e.g., mode: 0o755 for executable scripts.
Pass custom regexp, e.g., regexp: /^#!/ for strict shebang detection.
Use import statement instead of require(), or set type: 'module' in package.json and rename file to .mjs.
Use default import: import shebang from 'rollup-plugin-shebang-bin'
Run npm install rollup-plugin-shebang-bin --save-dev and ensure Node >= 14.18.