57 releases (27 breaking)

new 0.27.0 Sep 6, 2024
0.25.0 Aug 23, 2024
0.22.1 Jul 28, 2024
0.11.0 Mar 30, 2024
0.0.1 Mar 30, 2023

#24 in Programming languages

Download history 3501/week @ 2024-05-19 10903/week @ 2024-05-26 63491/week @ 2024-06-02 60854/week @ 2024-06-09 61928/week @ 2024-06-16 83798/week @ 2024-06-23 70423/week @ 2024-06-30 62423/week @ 2024-07-07 60024/week @ 2024-07-14 62525/week @ 2024-07-21 69881/week @ 2024-07-28 56785/week @ 2024-08-04 48326/week @ 2024-08-11 47778/week @ 2024-08-18 43879/week @ 2024-08-25 37234/week @ 2024-09-01

178,874 downloads per month
Used in 14 crates (11 directly)

MIT license

3MB
62K SLoC

Oxc Parser for JavaScript and TypeScript

Performance

The following optimization techniques are used:

  • AST is allocated in a memory arena (bumpalo) for fast AST drop
  • oxc_span::Span offsets uses u32 instead of usize
  • Scope binding, symbol resolution and complicated syntax errors are not done in the parser, they are delegated to the semantic analyzer

Usage

The parser has a minimal API with three inputs and one return struct ([ParserReturn]).

let parser_return = Parser::new(&allocator, &source_text, source_type).parse();

Example

https://github.com/Boshen/oxc/blob/main/crates/oxc_parser/examples/parser.rs

Visitor

See oxc_ast::Visit and oxc_ast::VisitMut

Visiting without a visitor

For ad-hoc tasks, the semantic analyzer can be used to get a parent pointing tree with untyped nodes, the nodes can be iterated through a sequential loop.

for node in semantic.nodes().iter() {
    match node.kind() {
        // check node
    }
}

See full linter example

Dependencies

~4–10MB
~93K SLoC