Registry / devops / yuku-parser

yuku-parser

JSON →
library0.5.28jsnpmunverified

High-performance JavaScript/TypeScript parser written in Zig, producing ESTree-compliant AST for JS/JSX and TypeScript-ESTree AST for TS/TSX. Features full support for Stage 3 decorators, import defer, import source, and hashbang. Provides fast offset-to-line/column resolution via locOf/locNear. Current stable version is 0.5.28. Released under Apache-2.0 license. Key differentiator: extreme speed (native Zig) while maintaining spec compliance identical to Acorn and @typescript-eslint/parser.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Package is ESM-only; CommonJS require not supported.

import { parse } from 'yuku-parser';

Exported from main entry point.

import { langFromPath } from 'yuku-parser';

Exported from main entry point.

import { sourceTypeFromPath } from 'yuku-parser';

Use import type for type-only imports in TypeScript; runtime import will fail because AST types are not values.

import type { Node, Statement, Expression, Identifier } from 'yuku-parser';

Parses a JSX/TSX file, converts offset to line/column, and shows diagnostics.

import { parse, langFromPath, sourceTypeFromPath } from 'yuku-parser'; const filePath = 'component.tsx'; const lang = langFromPath(filePath); // "tsx" const sourceType = sourceTypeFromPath(filePath); // "module" const source = ` import { useState } from 'react'; const App = () => { const [count, setCount] = useState(0); return <div>{count}</div>; }; `; const result = parse(source, { lang: lang, sourceType: sourceType }); console.log("AST:", result.program); console.log("Diagnostics:", result.diagnostics); // Convert offset to line:column if (result.program.body.length > 0) { const start = result.program.body[0].start; const { line, column } = result.locOf(start); console.log(`First statement starts at line ${line}, column ${column}`); }
Debug
Known footguns
breakingPackage is ESM-only; CommonJS require() will throw.
gotchaAST node types are exported as types only; cannot be used as runtime values.
gotchalocOf and locNear return line (1-based) and column (0-based), which may differ from some other parsers using 0-based lines.
deprecatedAST fields 'start' and 'end' use UTF-16 code units, not byte offsets.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
ahrefsbot
2
Resources