{"library":"oxc-parser","title":"Oxc Parser","description":"The `oxc-parser` package provides a high-performance JavaScript and TypeScript parser with a Node.js API, currently at version 0.126.0. It's part of the broader Oxc project, known for its fast Rust-based tooling. The project exhibits a rapid release cadence, with frequent updates incorporating new features, bug fixes, and occasional breaking changes as seen in recent `crates_v` releases. Oxc Parser generates an AST that is fully conformant with the ESTree standard for JavaScript/JSX and `@typescript-eslint/typescript-estree` for TypeScript, with minor deviations for Stage 3 decorators and specific import syntax proposals (`import defer`, `import source`). A key differentiator is its 'Fast Mode,' which disables semantic error reporting by default for performance-critical scenarios, leaving error checks to downstream tools. It also offers WASM support and direct ESM information extraction, making it suitable for parser plugins and code transformation tasks.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install oxc-parser"],"cli":null},"imports":["import { parseSync } from 'oxc-parser'","import { parse } from 'oxc-parser'","import { Visitor } from 'oxc-parser'","import type { Program } from '@oxc-project/types'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { parseSync, Visitor } from \"oxc-parser\";\nimport type { Statement, Program } from '@oxc-project/types';\n\nconst code = \"const message: String = /* 🤨 */ 'Hello, Oxc!';\\n console.log(message);\";\n\n// File extension is used to determine which dialect to parse source as (e.g., .js, .jsx, .ts, .tsx).\nconst filename = \"test.tsx\";\n\nconst result = parseSync(filename, code, {\n  sourceType: 'module',\n  astType: 'ts',\n  showSemanticErrors: true // Enable semantic checks for full error reporting\n});\n\nif (result.errors.length > 0) {\n  console.error('Parsing errors:', result.errors);\n} else {\n  console.log('Successfully parsed AST:', result.program.type);\n  // Example visitor to count statements\n  class StatementCounter extends Visitor {\n    statementCount = 0;\n    visitStatement(node: Statement) {\n      this.statementCount++;\n      super.visitStatement(node);\n    }\n  }\n  const counter = new StatementCounter();\n  counter.visitProgram(result.program as Program);\n  console.log(`Total statements: ${counter.statementCount}`);\n  console.log('ESM Info:', result.esm);\n}\n","lang":"typescript","description":"This quickstart demonstrates synchronous parsing of TypeScript code, enabling semantic error checks, and then traversing the generated AST using a custom visitor to count statements, also showing access to ESM information.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}