A webpack loader that compiles PEG.js grammar files into JavaScript parser modules. Current version 0.5.8 is stable with weekly npm downloads around 1,000. Requires peer dependencies PEG.js ^0.10.0 and webpack >=1. Supports options like cache, optimize, trace, allowedStartRules, and dependencies. Differentiated from alternatives like jison-loader by its tight integration with PEG.js and support for multiple parser options via query parameters.
npm install pegjs-loaderVerified import paths — ran on the pinned version, not inferred.
Configure webpack to use pegjs-loader on .pegjs files, then require and parse with the compiled parser.
Update grammars to be compatible with PEG.js 0.10.0. Refer to PEG.js changelog.
Use module.rules: [{ test: /\.pegjs$/, use: 'pegjs-loader' }] in webpack 2+.Append options as query string: 'pegjs-loader?cache=true'.
Ensure grammar files are compatible with PEG.js 0.9.0+
npm install --save-dev pegjs
Ensure pegjs-loader is not processed by babel; exclude node_modules or pegjs-loader from babel-loader rule
Upgrade pegjs-loader to v0.2.2 or later
Ensure all loader options are strings (e.g., 'true' instead of true)