Skip to content

Repository files navigation

Logo

NPM Version NPM Downloads sponsor

Yuku is a high-performance JavaScript and TypeScript compiler toolchain written in Zig. Spec-compliant, zero dependencies, fast by design.

Try it in the playground →

📖 Documentation

Visit yuku.fyi for the full documentation, guides, and API reference.

Parser

JavaScript

npm install yuku-parser
import { parse } from "yuku-parser";

const { program, comments, diagnostics } = parse("const x = 1 + 2;");

Outputs an ESTree / TS-ESTree-compatible AST matching Oxc. Runs 3-10x faster than alternatives on npm.

Zig

zig fetch --save git+https://github.com/yuku-toolchain/yuku.git
var tree = try parser.parse(allocator, "const x = 5;", .{});
defer tree.deinit();

Read the parser documentation →

Codegen

npm install yuku-codegen
import { parse } from "yuku-parser";
import { generate } from "yuku-codegen";

generate(parse("const x = 1 + 2;").program).code;
// "const x = 1 + 2;"

generate(parse("const x: number = 1;", { lang: "ts" }).program, { strip: true }).code;
// "const x = 1;"

generate(parse("const enabled = true;").program, { minify: true }).code;
// "const enabled=!0"

Emits a Source Map V3 in the same pass, ~2.5x faster than @babel/generator with source maps on:

const { program } = parse(source);
const { code, map } = generate(program, { sourceMap: { source } });

Read the codegen documentation →

Analyzer

npm install yuku-analyzer
import { Analyzer } from "yuku-analyzer";

const project = new Analyzer();

project.addFile("a.ts", `export const value = 1;`);
project.addFile("b.ts", `export { value as renamed } from "./a.ts";`);
project.addFile("c.ts", `import { renamed } from "./b.ts"; renamed;`);

project.module("c.ts").rootScope.find("renamed").definition().symbol.name;
// "value"

Scopes, symbols, resolved references, closures, and cross-file module linking, computed in one native pass.

Read the analyzer documentation →

Performance

Yuku prioritizes correctness while delivering top-tier speed and efficiency.

Parsing typescript.js (7.8 MB) · macOS (ARM), Apple M3, 16 GB · native benchmark comparing Yuku, Oxc, and other Zig/Rust parsers

Testing

Correctness in Yuku is not an afterthought. Yuku is 100% ECMAScript spec compliant. The parser is validated against a dedicated parser test suite: over 55,000 cases sourced from Test262, the TypeScript compiler, and Babel, with exact AST matching against independently generated ESTree / TS-ESTree snapshots. The suite syncs with upstream daily, and Yuku passes all of it with zero failures and zero AST mismatches.

Read how Yuku is tested →

🤝 Contributing

See CONTRIBUTING.md for setup, testing, and playground instructions.

⚖️ License

Yuku is free and open-source software licensed under the MIT License.

About

High-performance JavaScript/TypeScript compiler toolchain in Zig.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

924 stars

Watchers

7 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages