Socket
Book a DemoInstallSign in
Socket

esbuild-plugin-peggy

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-plugin-peggy

An esbuild plugin for importing PEG.js / Peggy grammar files directly into your JavaScript or TypeScript projects.

latest
Source
npmnpm
Version
0.0.0
Version published
Maintainers
1
Created
Source

Esbuild Plugin Peggy popper

Test Maintainability Coverage npm version npm downloads Bundle size Gitpod Ready

🔌 Seamlessly load .pegjs or .peggy grammar files directly into your esbuild pipeline

✨ Features

  • Compile .pegjs / .peggy files as ES modules with zero config
  • Fully compatible with both JavaScript and TypeScript
  • No Node.js-only dependencies get into your codebase — frontend safe!
  • Supports custom parser options and per-file overrides
  • Simple, fast, and modern integration with esbuild

📦 Installation

pnpm add esbuild-plugin-peggy

or

npm install esbuild-plugin-peggy

or

yarn add esbuild-plugin-peggy

🚀 Usage

// esbuild.config.ts
import { build } from "esbuild";
import { peggyPlugin } from "esbuild-plugin-peggy";

build({
  entryPoints: ["src/index.ts"],
  bundle: true,
  outfile: "dist/bundle.js",
  plugins: [peggyPlugin()],
});

Then in your source code:

import parser from "./grammar.pegjs";

const result = parser.parse("your input here");

⚙️ Plugin Options

You can pass either a global config or a list of per-file configs using ParserBuildOptions from peggy.

Global options

peggyPlugin({
  allowedStartRules: ["Expression"],
});

Per-file options

peggyPlugin([
  {
    pathPattern: /calculator\.pegjs$/,
    options: { allowedStartRules: ["Calc"] },
  },
]);

📁 Supported File Types

  • .pegjs
  • .peggy

🛠 Example

import parser from "./math.pegjs";

console.log(parser.parse("2 + 2")); // 4

✅ Why Use This?

  • Skip manual parser builds — just import and use
  • Compatible with modern tooling and frameworks
  • Great for in-browser parsing and visual tooling
  • Keeps frontend builds clean of Node-only deps
Star this [repository](https://github.com/tiny-md/esbuild-plugin-peggy) and share it with friends.

📜 License

Licensed under the MPL-2.0 license. © Mayank Chaudhari

📚 Enroll in [our courses](https://mayank-chaudhari.vercel.app/courses) or [sponsor](https://github.com/sponsors/mayank1513) our work.

Made with 💖 by Mayank Kumar Chaudhari

Keywords

esbuild

FAQs

Package last updated on 22 Mar 2025

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