rollup-plugin-strip-shebang
TypeScript icon, indicating that this package has built-in type declarations

1.2.10 • Public • Published

rollup-plugin-strip-shebang

CircleCI npm codecov dependencies dev dependencies peer dependencies packagephobia bundlephobia types Known Vulnerabilities license

A Rollup.js plugin to remove and optionally extract shebang.

Install

npm i rollup-plugin-strip-shebang

Usage

// example.js
#!/usr/bin/env node
 
console.log("Hi!");
// rollup.config.js
import stripShebang from "rollup-plugin-strip-shebang";
 
export default {
 
  input: "example.js",
 
  output: {
    file: "bin/cli.js",
    format: "cjs"
  },
 
  plugins: [
    stripShebang()
  ]
 
};

Features

Options

include / exclude

minimatch pattern to be used as filter, see createFilter documentation.

syntax

includeArray<string | RegExp> | string | RegExp | null;
excludeArray<string | RegExp> | string | RegExp | null;

capture

You can pass a capture function or object to get the stripped shebang in case you need it later.

function

syntax

capture: (shebang: string) => void;

example

let shebang;
...
  plugins: [
    strip({
      capture(capturedShebang) {
        shebang = capturedShebang;
      },
    }),
  ]
...
console.log(shebang);

object

syntax

captureObject;

example

let capture = {};
...
  plugins: [
    strip({
      capture,
    }),
  ]
...
console.log(capture.shebang);

sourcemap

You can pass sourcemap: false to speed things up a bit if you don't need source maps. Anything other than false will default to true.

syntax

sourcemapboolean = true;

example

...
  output: {
    file: "bin/lib.js",
    sourcemap: false,
  },
  plugins: [
    strip({
      sourcemap: false,
    }),
  ]
...

⚠️ Note that you will get a warning if you set rollup to generate source maps and set this to false.

License

MIT © 2019 Manuel Fernández

Package Sidebar

Install

npm i rollup-plugin-strip-shebang

Weekly Downloads

48

Version

1.2.10

License

MIT

Unpacked Size

24.2 kB

Total Files

10

Last publish

Collaborators

  • manferlo81