{"id":19122,"library":"babel-plugin-pegjs-inline-precompile","title":"babel-plugin-pegjs-inline-precompile","description":"Babel plugin that precompiles inline PEG.js grammar expressions at build time. Version 0.1.1, limited release cadence. Replaces runtime parsing with a compile-time step using a tagged template literal `peg`, requiring the complementary `pegjs-inline-precompile` runtime helper. Differentiates from other PEG.js integrations by minimizing runtime overhead and bundling size.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","babel","babel-plugin","ast"],"install":[{"cmd":"npm install babel-plugin-pegjs-inline-precompile","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-pegjs-inline-precompile","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-pegjs-inline-precompile","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PEG.js dependency for grammar parsing and code generation","package":"pegjs","optional":true},{"reason":"Runtime helper required for the `peg` tagged template literal","package":"pegjs-inline-precompile","optional":true}],"imports":[{"note":"Default export, not a named export.","wrong":"import { peg } from 'pegjs-inline-precompile';","symbol":"peg","correct":"import peg from 'pegjs-inline-precompile';"},{"note":"CommonJS require returns the default as the module exports object.","wrong":"const { peg } = require('pegjs-inline-precompile');","symbol":"peg","correct":"const peg = require('pegjs-inline-precompile');"},{"note":"Plugin name must be the full package name; omitting 'babel-plugin-' prefix is a common mistake.","wrong":"{ \"plugins\": [\"pegjs-inline-precompile\"] }","symbol":"plugin","correct":"// .babelrc\n{ \"plugins\": [\"babel-plugin-pegjs-inline-precompile\"] }"}],"quickstart":{"code":"// Install dependencies\n// npm install babel-plugin-pegjs-inline-precompile pegjs pegjs-inline-precompile\n\n// .babelrc\n{\n  \"plugins\": [\"babel-plugin-pegjs-inline-precompile\"]\n}\n\n// source.js\nimport peg from 'pegjs-inline-precompile';\n\nconst parser = peg`\n  // Grammar\n  Expression = Term (\"+\" Term)*\n  Term = Number (\"*\" Number)*\n  Number = [0-9]+\n`;\n\nexport default function evaluate(input) {\n  return parser.parse(input);\n}","lang":"javascript","description":"Shows installation, Babel configuration, and usage of the peg tagged template literal for inline PEG.js grammar precompilation."},"warnings":[{"fix":"Ensure 'pegjs-inline-precompile' is in your dependencies, not just devDependencies.","message":"The plugin requires the 'pegjs-inline-precompile' runtime package to be installed; otherwise, the `peg` import will fail.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Install 'pegjs' as a dependency if you plan to use PEG.js outside of the precompilation context.","message":"The plugin itself does not include PEG.js; you must install 'pegjs' separately if you need the PEG.js runtime for dynamic grammar compilation.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always use `peg` as the tag function name in your source code.","message":"The plugin only processes tagged template literals with the exact identifier name 'peg'; custom names will not be precompiled.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install pegjs-inline-precompile' and add to dependencies.","cause":"Missing runtime package dependency.","error":"Module not found: Can't resolve 'pegjs-inline-precompile'"},{"fix":"Install 'pegjs-inline-precompile' and ensure it is resolvable in node_modules.","cause":"Babel plugin unable to locate the runtime module.","error":"Error: The 'pegjs-inline-precompile' plugin requires a matching runtime package, but it is not loaded."},{"fix":"Add 'import peg from 'pegjs-inline-precompile';' at top of file.","cause":"Missing import of 'peg' from 'pegjs-inline-precompile'.","error":"ReferenceError: peg is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}