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 🙏

© 2026 – Pkg Stats / Ryan Hefner

esbuild-peggy

v1.0.7

Published

esbuild plugin for importing PEG.js / Peggy parsers directly in JavaScript / TypeScript

Readme

esbuild-peggy

An esbuild plugin for bundling Peggy.js / PEG.js parsers directly into JavaScript and TypeScript source files.

Available as esbuild-peggy on npm.

Quick Start

  1. Add esbuild-peggy as a dependency - typically a devDependency - within your package.json; e.g.:

    $ npm install --save-dev esbuild-peggy

    or

    // FILE: package.json
    {
      "devDependencies": {
        "esbuild-peggy": "latest"
      }
    }
  2. Configure esbuild-peggy as a plugin within your esbuild build script. E.g.:

    // FILE: esbuild.js
    import { build } from "esbuild";
    import { peggyPlugin } from "esbuild-peggy";
    
    build({
      // ...
      plugins: [ peggyPlugin() ],
      loader: {
        ".pegjs": "js",
        ".peggy": "js"
      }
    });

    Note that you may optionally pass arbitrary Peggy.js ParserOptions (as a map) in the first parameter to the peggyPlugin() function.

    Note also that esbuild-peggy is fully compatible with esbuild's "watch mode", and will automatically rebuild the generated parser implementation (and subsequently any appropriately defined dependencies) whenever the underlying .pegjs/.peggy source is modified (in that context).

  3. Create your grammar file with a .pegjs or .peggy extension; e.g.:

    // FILE: grammar.pegjs
    START = Number
    Number = "-"? [0-9]+ ("."[0-9]+)? { return parseFloat(text()); }
  4. Import the grammar file directly in your JavaScript or TypeScript file; e.g.:

    // FILE: index.ts
    import parser from "./grammar.pegjs";
    console.log(parser.parse("-3.14"));

See the examples directory within this repository for a complete demonstration of using esbuild-peggy with the esbuild bundler in JavaScript and TypeScript.

Licensing

The esbuild-peggy library and related documentation are made available under an MIT License. For details, please see the LICENSE.txt file in the root directory of the repository.

Versioning

This module follows the semver version numbering strategy.

About

About esbuild

esbuild is a tightly-designed, blazingly-fast, extraordinarily-common but oddly under-appreciated (though this seems to be changing) build tool/bundler framework implemented in golang with JavaScript/TypeScript bindings.

In case the npm-compare.com link above happens to go bad in the future note that as of this writing (mid-May 2025) that chart currently shows:

  • esbuild with ~60 million weekly downloads from npm
  • rollup with ~40 million weekly downloads.
  • webpack with ~32 million weekly downloads.
  • vite with ~28 million weekly downloads.

but note that vite currently embeds both rollup and esbuild, so that alone probably accounts for roughly half of the 60 million esbuild installs and 3/4ths of the 40 million rollup installs.

About PEG.js/Peggy.js

Peggy is the spiritual successor to PEG.js, a robust but largely stagnant parser generator for the JavaScript stack, both server (node.js, etc) and client (browser).

(PEG.js has not been refreshed for nearly a decade - arguably it doesn't strictly need to be: AST-style grammars have been a mature, well-established technology for easily half a century. But PEG.js still accrues more than half a million installs off of npmjs.org per week.)

About esbuild-peggy

esbuild-peggy is a straightforward esbuild plugin, implemented in TypeScript, that enables the (ESM) import or (CJS) require of .pegjs or .peggy grammar files directly within JavaScript or TypeScript source files (when bundled with esbuild).

For a complete working example of using esbuild-peggy in JavaScript or TypeScript see examples directory within the main source repository.

Contributions Welcome

This plugin was initially developed to "scratch my own itch" (address a specific need I organically encountered), but (a) seems to be moderately robust already and (b) could be generalized to address additional needs and use-cases as they are identified.

Should you have any questions, encounter any issues, or have any feature requests/bug-fixes/enhancements you'd like to propose, please feel free submit them as issues or pull requests on the GitHub platform (or other channels as appropriate).

See HACKING.md for more information about building this module from source and other development related topics.