yuku
A JavaScript and TypeScript compiler toolchain written in Zig
Last updated 17 days ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install yuku 
SYNC missed versions from official npm registry.
Yuku

Parse, analyze, walk, build, and print JavaScript and TypeScript.

One package, no third-party dependencies. Written in Zig, running in Node.js, Bun, Deno, browsers, and edge runtimes.

Docs · Playground · GitHub

npm install yuku

It runs natively where its addon for the platform installs, and as WebAssembly everywhere else. Cloudflare Workers and Vercel Edge run WebAssembly only from a file, so there also install @yuku-toolchain/wasm.

import { b, parse, print, walk } from "yuku";

const file = parse(`
  const RATE = 0.2;
  export const tax = (price: number) => price * RATE;
  export const scale = (RATE: number) => RATE * 2;
`, { path: "tax.ts", analyze: true });

const rate = file.rootScope.find("RATE");

walk(file.program, {
  Identifier(node, ctx) {
    if (file.referenceOf(node)?.binding === rate) ctx.replace(b.Literal({ value: 0.2 }));
  },
});

print(file, { strip: true }).code;
// const RATE = 0.2;
// export const tax = (price) => price * 0.2;
// export const scale = (RATE) => RATE * 2;

The guide documents how to parse, walk and build, analyze, and print.

Performance

yuku parses faster than the alternatives on npm, on small and large files.

Parsing react.js (70 KB) on npm

Parsing typescript.js (7.8 MB) on npm

Analyzing a whole codebase, it is faster than typescript-eslint and the TypeScript API, and on a single large file too.

Analyzing three.js (755 files) on npm

Analyzing typescript.js (7.8 MB) on npm

Measured on an Apple M3, see the parser and analyzer benchmarks. Pass one walk all your visitors.

License

MIT

Current Tags

  • 0.28.0                                ...           latest (17 days ago)

24 Versions

  • 0.28.0                                ...           17 days ago
  • 0.27.0                                ...           25 days ago
  • 0.26.1                                ...           a month ago
  • 0.26.0                                ...           a month ago
  • 0.25.0                                ...           a month ago
  • 0.24.1                                ...           a month ago
  • 0.24.0                                ...           a month ago
  • 0.23.0                                ...           a month ago
  • 0.22.2                                ...           a month ago
  • 0.22.1                                ...           a month ago
  • 0.22.0                                ...           a month ago
  • 0.21.0                                ...           a month ago
  • 0.20.1                                ...           a month ago
  • 0.20.0                                ...           a month ago
  • 0.2.12                                ...           10 months ago
  • 0.2.9                                ...           10 months ago
  • 0.2.7                                ...           a year ago
  • 0.2.5                                ...           a year ago
  • 0.2.4                                ...           a year ago
  • 0.2.3                                ...           a year ago
  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.0                                ...           a year ago
Maintainers (1)
Downloads
Total 37
Today 0
This Week 2
This Month 37
Last Day 0
Last Week 11
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE