rollup-plugin-executable-output
raw JSON → 1.3.0 verified Mon Apr 27 auth: no javascript
Rollup plugin (v1.3.0, stable) that applies chmod 755 to output files, making them executable. Designed to work alongside rollup-plugin-preserve-shebang for CLI scripts. Unlike older plugins like rollup-plugin-chmod, it correctly handles multiple outputs per bundle and uses Rollup's generateBundle hook. Minimal dependencies; requires Rollup >=1.0.0. Release cadence is low; last update 2022. Key differentiator: no bugs when used with multiple outputs or code splitting.
Common errors
error Error: The plugin 'rollup-plugin-executable-output' is not compatible with Rollup 4. Upgrade to Rollup 3 or use a different plugin. ↓
cause Rollup 4 deprecated the 'generateBundle' hook signature used by older versions.
fix
Use Rollup 3.x or switch to 'rollup-plugin-chmod' which may have been updated.
error TypeError: executable is not a function ↓
cause Importing named export 'executable' instead of default export.
fix
Use 'import executable from ...'
error Error: [plugin: executable] Cannot read properties of undefined (reading 'fileName') ↓
cause Using 'output.dir' with multiple chunks; plugin expects single file output.
fix
Use 'output.file' or avoid using this plugin with directory output.
Warnings
gotcha Plugin only applies chmod 755 to outputs generated by Rollup; it does not handle files copied by other plugins (e.g., rollup-plugin-copy). ↓
fix Use a dedicated chmod utility or post-build script for external files.
gotcha The plugin must be placed after other output-modifying plugins (e.g., shebang) in the plugins array to ensure the final output is made executable. ↓
fix Order plugins so executable() is last among those that modify output.
gotcha Does not work with Rollup's 'output.dir' option for multiple chunks; only intended for single-file outputs via 'output.file'. ↓
fix Use only 'output.file' or consider 'rollup-plugin-chmod' for directories.
deprecated No active development; last update 2022. May not support Rollup 4+ hooks if they change. ↓
fix Pin Rollup to version 3 or test compatibility.
Install
npm install rollup-plugin-executable-output yarn add rollup-plugin-executable-output pnpm add rollup-plugin-executable-output Imports
- default wrong
const executable = require('rollup-plugin-executable-output')correctimport executable from 'rollup-plugin-executable-output' - executable
import executable from 'rollup-plugin-executable-output' - TypeScript usage
// No types included; use @types/rollup or declare module
Quickstart
// rollup.config.js
import executable from 'rollup-plugin-executable-output';
import shebang from 'rollup-plugin-preserve-shebang';
export default {
input: 'src/cli.js',
output: {
file: 'dist/cli.js',
format: 'cjs',
},
plugins: [shebang(), executable()],
};