{"library":"meriyah","title":"Meriyah JavaScript Parser","description":"Meriyah is a highly performant and stable JavaScript parser, currently at version 7.1.0, designed for 100% compliance with the ECMAScript® 2024 (ES-262 15th Edition) standard. It provides an ESTree-compatible Abstract Syntax Tree and operates without backtracking, contributing to its low memory footprint. While it actively supports Annex B (Web Browsers) features, JSX parsing, and select TC39 Stage 3 proposals like Decorators and JSON Modules via an opt-in `next` flag, it notably does *not* support TypeScript or Flow syntax. The project maintains a steady release cadence, frequently updating to reflect the latest ECMAScript specifications and address bug fixes, as evidenced by recent v6 and v7 patch and minor releases, ensuring it remains a cutting-edge tool for syntactic analysis.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install meriyah"],"cli":null},"imports":["import { parse } from 'meriyah';","import { isParseError } from 'meriyah';","import type { ParserOptions } from 'meriyah';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { parse, isParseError } from 'meriyah';\nimport type { Program } from 'estree'; // Assuming ESTree types are needed for the result\n\nconst javascriptCode = `\n  // This is a complex JavaScript module demonstrating various features.\n  import { someUtil } from './utils.js';\n\n  @debounce(300)\n  class MyClass {\n    #privateField = 42; // Private class field (ES2022)\n\n    constructor(name) {\n      this.name = name;\n    }\n\n    // A method with decorators (TC39 Stage 3, requires 'next' option)\n    @log\n    greet(param) {\n      console.log(`Hello, ${this.name}! ${param}`);\n      return someUtil(this.#privateField);\n    }\n  }\n\n  export const instance = new MyClass('Meriyah User');\n\n  // Example of Annex B feature (non-strict mode)\n  // function foo() { 'use strict'; with (obj) {} } // This would error in strict mode\n  \n  // A regular expression with newer features (requires Node.js >= 24 for full validation)\n  const regex = /(?<word>\\w+)/d; \n  if (\"test\".match(regex)) {\n    console.log(\"Matched!\");\n  }\n`;\n\ntry {\n  const ast: Program = parse(javascriptCode, {\n    sourceType: 'module', // Parse as an ES module\n    ranges: true,        // Include start/end offsets for each node\n    loc: true,           // Include line/column location information\n    next: true,          // Enable TC39 Stage 3 proposals (e.g., Decorators)\n    jsx: false,          // Explicitly disable JSX (if not needed)\n    webcompat: true,     // Enable web compatibility (Annex B)\n    validateRegex: true, // Validate regular expressions with the current JS runtime\n  });\n\n  console.log('Successfully parsed AST:');\n  // console.log(JSON.stringify(ast, null, 2)); // Uncomment to see the full AST\n  console.log(`Program type: ${ast.type}`);\n  console.log(`First statement type: ${ast.body[0].type}`);\n\n} catch (e: any) {\n  if (isParseError(e)) {\n    console.error(`Meriyah Parse Error: ${e.message} at line ${e.loc?.line}, column ${e.loc?.column}`);\n  } else {\n    console.error('An unexpected error occurred:', e.message);\n  }\n}","lang":"typescript","description":"Demonstrates parsing a complex JavaScript module with various features, including ESNext proposals, web compatibility, location tracking, and error handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}