npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parcel-plugin-shebang

v1.4.1

Published

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

Downloads

110

Readme

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.

| Name | Type | Description | | ------------- |----------| ---------------------------------------------------------------------------- | | interpreter | string | Name of interpreter. | | files | string[] | 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.