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.

npm install yuku-parser
INSTALL
IMPORT
SIG · YUKU-PARSER
Y
yuku-parser
devopsjavascriptv0.5.28
harness data pending
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.

parse
import { parse } from 'yuku-parser';
const { parse } = require('yuku-parser');
Package is ESM-only; CommonJS require not supported.
langFromPath
import { langFromPath } from 'yuku-parser';
import { langFromPath } from 'yuku-parser/lang';
Exported from main entry point.
sourceTypeFromPath
import { sourceTypeFromPath } from 'yuku-parser';
import { sourceTypeFromPath } from 'yuku-parser/path';
Exported from main entry point.
Node type
import type { Node, Statement, Expression, Identifier } from 'yuku-parser';
import { Node } from 'yuku-parser';
Use import type for type-only imports in TypeScript; runtime import will fail because AST types are not values.

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 issues
breakingPackage is ESM-only; CommonJS require() will throw.
fix
Use import syntax or dynamic import().
affects: >=0.1
gotchaAST node types are exported as types only; cannot be used as runtime values.
fix
Use import type ... from 'yuku-parser' for type annotations; do not import for runtime access.
affects: >=0.1
gotchalocOf and locNear return line (1-based) and column (0-based), which may differ from some other parsers using 0-based lines.
fix
When comparing with ESTree 'loc' values, lines are 1-based and columns 0-based.
affects: >=0.1
deprecatedAST fields 'start' and 'end' use UTF-16 code units, not byte offsets.
fix
Use locOf() to convert to line/column if byte positions are needed; otherwise handle UTF-16 offsets.
affects: >=0.1
Errors
Common errors & fixes
SyntaxError: Unexpected token
Source contains syntax that is not valid JS/TS in the specified lang or sourceType.
fix
Check lang and sourceType options match the file content; ensure source is valid.
TypeError: (0 , yuku_parser.parse) is not a function
Using CommonJS require with ESM-only package.
fix
Switch to import { parse } from 'yuku-parser'; or use dynamic import().
Module '"yuku-parser"' has no exported member 'Node'.
Trying to import type 'Node' as a runtime value.
fix
Use import type { Node } from 'yuku-parser'; for type-only imports.
Cannot find module 'yuku-parser' or its corresponding type declarations.
Package not installed or TypeScript version incompatible (needs moduleResolution: node16/nodenext).
fix
Ensure package is installed; set 'moduleResolution': 'node16' or 'nodenext' in tsconfig.
Upgrade
Version history
0.5.28latest on npm
Audit
Dependencies
yuku-astoptionalCompanion toolkit for AST walking, builders, type guards, and validators
Agent activity
19 hits · last 30 days
node
16
Resources
yuku-parser — npm install yuku-parser · libregistry