#javascript-linter #minify #typescript-parser #linter

oxc_codegen

A collection of JavaScript tools written in Rust

139 releases (87 breaking)

Uses new Rust 2024

new 0.90.0 Sep 18, 2025
0.88.0 Sep 15, 2025
0.79.1 Jul 31, 2025
0.61.2 Mar 23, 2025
0.3.0 Nov 6, 2023

#798 in Programming languages

Download history 20790/week @ 2025-05-29 18455/week @ 2025-06-05 24959/week @ 2025-06-12 24202/week @ 2025-06-19 21985/week @ 2025-06-26 15520/week @ 2025-07-03 16703/week @ 2025-07-10 17998/week @ 2025-07-17 20537/week @ 2025-07-24 24267/week @ 2025-07-31 24746/week @ 2025-08-07 25935/week @ 2025-08-14 29858/week @ 2025-08-21 22579/week @ 2025-08-28 23976/week @ 2025-09-04 18723/week @ 2025-09-11

100,534 downloads per month
Used in 63 crates (10 directly)

MIT license

3.5MB
62K SLoC

Oxc Codegen

High-performance code generation from AST back to JavaScript/TypeScript source code.

Overview

This crate converts AST nodes back into source code strings, supporting JavaScript, TypeScript, and JSX. It's designed for speed and correctness, producing clean, readable output.

Key Features

  • Fast code generation: Optimized for performance with minimal allocations
  • Source map support: Generate accurate source maps during output
  • Configurable formatting: Control whitespace, semicolons, and other formatting options
  • Comment preservation: Maintain comments during code generation
  • Binary expression optimization: Intelligent parentheses insertion

Architecture

Code Generation Pipeline

  1. AST Traversal: Walk through AST nodes systematically
  2. Token Generation: Convert nodes to appropriate tokens/strings
  3. Formatting: Apply whitespace, indentation, and style rules
  4. Source Mapping: Track original source positions if enabled

Design Principles

  • Correctness: Generated code must be functionally equivalent to original
  • Performance: Minimize string allocations and copying
  • Readability: Produce clean, well-formatted output
  • Fidelity: Preserve semantic meaning and behavior

The codegen is adapted from esbuild's approach, optimized for Rust and oxc's AST structure.

Dependencies

~8.5MB
~148K SLoC