esbuild plugin that allows importing PEG.js/Peggy grammar files (.pegjs/.peggy) directly in JavaScript/TypeScript bundles. Current stable version is 1.0.7, requiring Node >=20 and npm >=10. It automatically rebuilds parsers when grammar files change, fully supports esbuild watch mode, and ships TypeScript types. Differentiates from similar tools (like pegjs-loader for webpack) by targeting esbuild's speed and simplicity.
npm install esbuild-peggyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures esbuild with the peggy plugin, bundles a TypeScript file that imports a PEG.js grammar, and parses an input.
Install peer dependencies: npm install --save-dev esbuild peggy
Use import syntax or use dynamic import: const { peggyPlugin } = await import('esbuild-peggy');Upgrade Node to version 20 or higher.
Use .peggy extensions and Peggy's API for future-proofing.
Add loader: { '.pegjs': 'js', '.peggy': 'js' } to your esbuild config.npm install --save-dev esbuild-peggy
Use 'import { peggyPlugin } from "esbuild-peggy"' instead of require().Add loader: { '.pegjs': 'js', '.peggy': 'js' } to the build options.Add plugins: [ peggyPlugin() ] to the build configuration.