Vite plugin that automatically compiles Peggy (PEG.js) grammar files (.pegjs, .peggy) into JavaScript parser modules during the build process. Version 2.0.1 supports Vite and accepts all standard Peggy options (cache, optimize, trace, dependencies, allowedStartRules). Released under MIT license. Alternatives include manual compilation or webpack's peggy-loader; this integrates seamlessly with Vite's plugin system and respects Vite's ESM transform.
npm install vite-plugin-peggy-loaderVerified import paths — ran on the pinned version, not inferred.
Configures Vite to compile .pegjs files on import using Peggy with caching and speed optimization.
Upgrade your grammar toolchain to Peggy >=1.2.0.
Use the `optimize` option instead of `optimizeParser`.
Use `import * as parser from './grammar.pegjs'` and call `parser.parse(input)`.
Rename your files to `.pegjs` or modify the plugin's source to include `.peggy`.
Manually import the dependency modules in your code or configure Vite to handle them.
Run `npm install vite-plugin-peggy-loader`. If using TypeScript, ensure `tsconfig.json` has `"moduleResolution": "node"` and `"esModuleInterop": true`.
Use Node >=12.20.0 or <14. It is an ESM package; use dynamic import if CommonJS is required.
Use `import peggyLoader from 'vite-plugin-peggy-loader'` (default import) or `import { peggyLoader } from 'vite-plugin-peggy-loader'` (named import) as available from version 2.0.1.