Socket
Book a DemoInstallSign in
Socket

parcel-plugin-shebang

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parcel-plugin-shebang

Plugin to generate shebang / hashbang for Parcel v1.x.x.

1.4.1
latest
Source
npmnpm
Version published
Weekly downloads
17
-34.62%
Maintainers
1
Weekly downloads
 
Created
Source

npm-version npm-download

parcel-plugin-shebang

#!/usr/bin/env node

Do you want your bundles generated by Parcel to have a shebang and it was easy to start from the console? This plugin allows this. You can build CLI applications in a simple way!

Installing

To install the plugin simply download the module.
You can use npm for this.

npm i -D parcel-plugin-shebang

Getting Started

After successful installation, the plugin should work.
If you use this plugin without configuration (which is described below) it will generate for you shebang automagically. However, the plugin only works when it finds a shebang line in source files that are entry points of Parcel.

Without this plugin, if you place a shebang line in the source file, Parcel will leave it in code and treat it the same as normal JavaScript code. Unfortunately, after running this file you will get SyntaxError. This plugin is designed to move the shebang line to the very top of the file so that it does not cause any syntax problems.

Here you can find a problem that tries to solve this plugin:
https://github.com/parcel-bundler/parcel/issues/2381

Configuration

The plugin has an optional configuration that allows you to generate shebang in bundle files. This is useful if you want your source files to not have a shebang.

There are two ways to configure the plugin:

  • You can use a dedicated configuration .shebangrc file.
  • Alternatively, you can save the configuration in the package.json file.

The configuration of the plugin is an array of objects describing the name of the interpreter and the array of files for which this interpreter is to be used.

An array can contain many objects.
If the path to the file repeats in the next object, the interpreter from the first passed object containing the given file will be used.

NameTypeDescription
interpreterstringName of interpreter.
filesstring[]Array of relative paths to the files in which the interpreter is to be used.

.shebangrc

[
  {
    "interpreter": "node",
    "files": [
      "./cli.ts"
    ]
  }
]

package.json

"shebang": [
  {
    "interpreter": "node",
    "files": [
      "./cli.ts"
    ]
  }
]

Now if you run the command:

parcel build ./cli.ts

The resulting file should contain a shebang with a node interpreter.

Keywords

parcel-bundler

FAQs

Package last updated on 12 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.