rollup-plugin-thatworks

raw JSON →
1.0.4 verified Mon Apr 27 auth: no javascript

A collection of Rollup plugins providing chmod (set executable permissions), directory resolver (allow bare directory imports), and shebang (preserve #! lines) functionality. Current version is 1.0.4, maintained by Harald Rudell. The package bundles three distinct plugins useful for building Node.js CLI executables with Rollup. It has a slow release cadence and is a niche alternative to using individual plugins like rollup-plugin-chmod, rollup-plugin-node-resolve with custom options, and rollup-plugin-preserve-shebang.

error Error: Cannot find module 'rollup-plugin-thatworks'
cause Package not installed or not in node_modules.
fix
Run 'npm install rollup-plugin-thatworks --save-dev'
error TypeError: chmod is not a function
cause Importing default instead of named export.
fix
Change 'import chmod from ...' to 'import { chmod } from ...'
error Error: [plugin: shebang] Shebang must come first in the file.
cause source file contains #! not on first line or output code has added extra lines before shebang.
fix
Ensure the input file's shebang is on the very first line (line 1).
breaking Requires Rollup 1.1+; incompatible with Rollup 0.x.
fix Update Rollup to version 1.1 or higher.
deprecated The name 'debnugPlugin' is a typo and may be removed in a future major version.
fix Use import { debnugPlugin } but be aware it's misspelled; alternate plugin rollup-plugin-debug exists.
gotcha directoryResolver only works for directory imports; does not resolve file extensions.
fix Ensure directories have an index.js or index.mjs file; for file resolution, use rollup-plugin-node-resolve.
npm install rollup-plugin-thatworks
yarn add rollup-plugin-thatworks
pnpm add rollup-plugin-thatworks

A Rollup configuration that uses directoryResolver, shebang, and chmod plugins to build a CLI executable from ES modules.

// rollup.config.js
import { chmod, directoryResolver, shebang } from 'rollup-plugin-thatworks';
export default {
  input: 'src/index.js',
  output: {
    file: 'dist/cli.mjs',
    format: 'esm'
  },
  plugins: [
    directoryResolver({ paths: 'src' }),   // import from 'dir' instead of '../dir'
    shebang(),                              // preserve #!/usr/bin/env node
    chmod({ mode: 0o755 })                  // set executable permissions
  ]
};