npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@willbooster/tree-sitter-ruby

v27.1.1

Published

Ruby grammar for tree-sitter

Readme

@willbooster/tree-sitter-ruby

npm version license Test Test rust semantic-release wbfy crates.io

Ruby grammar for tree-sitter, forked from tree-sitter/tree-sitter-ruby. We are grateful to its authors and contributors. This is not an official release of that project.

This fork extends the upstream grammar to parse anonymous block arguments before a closing parenthesis on their own line, brace blocks right after a method name, unary plus arguments, << right after an operand as a shift, operators after a local variable as binary (total -1, items <<item, tracking assignments and parameters per method and block), command calls in endless methods, heredocs opened inside heredoc bodies and literals, lines starting with a logical operator (Ruby 4.0), and Unicode symbols, and ends line comments at included range boundaries (<% # note %> in a template), with a parser generated by WillBooster/tree-sitter, whose compact parse tables make the parser smaller. The parser carries that fork's own ABI number (0x5742000e); upstream's tree-sitter runtime and incompatible ABI versions of the fork's runtime reject it. If the open heredocs and literals cannot fit the runtime's serialization buffer, the scanner drops them, so their bodies are parsed as code instead of aborting the process.

Support Scope

This fork maintains only full parsing, optimized for binary size and parse speed: valid code as found in real-world projects yields a correct tree, rare valid syntax whose support would noticeably grow the parser may instead yield ERROR or MISSING nodes, and valid code never yields an incorrect tree without them. Any input parses without crashing, hanging, or taking more than linear time. Invalid input may parse without ERROR or MISSING nodes. Incremental parsing is not supported, and no queries (highlights, locals, injections, tags) are shipped. Node types, field names, and the trees that error recovery produces may change; such changes are released as new major versions.

Usage

The npm package ships tree-sitter-ruby.wasm for @willbooster/web-tree-sitter 28.0.0, which runs in Node.js, Bun, browsers, and Cloudflare Workers.

In Node.js and Bun, load the grammar from its path:

import { fileURLToPath } from 'node:url';

import { Language, Parser } from '@willbooster/web-tree-sitter';

await Parser.init();
const parser = new Parser();
const wasmPath = fileURLToPath(import.meta.resolve('@willbooster/tree-sitter-ruby/tree-sitter-ruby.wasm'));
parser.setLanguage(await Language.load(wasmPath));
const tree = parser.parse('puts "Hello"\n');

In browsers, load the grammar from its URL. With Vite:

import rubyUrl from '@willbooster/tree-sitter-ruby/tree-sitter-ruby.wasm?url';
import { Language, Parser } from '@willbooster/web-tree-sitter';
import runtimeUrl from '@willbooster/web-tree-sitter/web-tree-sitter.wasm?url';

await Parser.init({ locateFile: () => runtimeUrl });
const parser = new Parser();
parser.setLanguage(await Language.load(rubyUrl));

In Cloudflare Workers, which do not allow compiling Wasm at run time, import both .wasm files as modules:

import ruby from '@willbooster/tree-sitter-ruby/tree-sitter-ruby.wasm';
import { Language, Parser } from '@willbooster/web-tree-sitter';
import runtime from '@willbooster/web-tree-sitter/web-tree-sitter.wasm';

await Parser.init({ wasmModule: runtime });
const parser = new Parser();
parser.setLanguage(await Language.load(ruby));

The package also ships the node types in src/node-types.json.

In Rust, depend on the crate and on willbooster-tree-sitter 28.0.0, the runtime this package is tested and fuzzed with:

cargo add [email protected] --rename tree-sitter
cargo add willbooster-tree-sitter-ruby --rename tree-sitter-ruby
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_ruby::LANGUAGE.into())?;

Development

mise install
bun install --frozen-lockfile
bun run test/ci-setup
bun run build/ci
bun run verify
bun run test
cargo test
  • bun run test/ci-setup: run once to install Chromium before bun run test.
  • bun run build/ci: run before bun run test, and commit src/ after changing grammar.js, tree-sitter.json, test/corpus/, or tracked files in examples/. Stage added or removed examples/ files with git add -A examples before generating so the profile sees them.
  • script/parse-examples: run without arguments to update script/known-failures.txt after a grammar or pin change alters which example files fail to parse.
  • script/tree-sitter: use for direct CLI commands such as script/tree-sitter parse file.rb so they run the WillBooster/tree-sitter version locked in Cargo.lock.

References