Repository Structure
The repository is organized into several top-level directories:crates/ - Core Functionality
The heart of Oxc. All Rust crates live here, organized by functionality:
Foundation Crates
oxc_allocator- Arena-based memory allocator for zero-copy operationsoxc_span- Source position tracking and text manipulationoxc_syntax- JavaScript/TypeScript language definitions and token typesoxc_diagnostics- Error reporting with rich error messagesoxc_ast- Abstract Syntax Tree definitions and utilities
Parser and Analysis
oxc_parser- Hand-written recursive descent JS/TS parseroxc_semantic- Semantic analysis, symbol resolution, scope analysisoxc_cfg- Control Flow Graph construction
Tools
oxc_linter- Linting engine with 200+ rules (see Adding Rules)oxc_formatter- Code formatting (Prettier-compatible)oxc_transformer- Code transformation and transpilation (Babel-like)oxc_minifier- Code size optimization and minificationoxc_codegen- AST to source code generation with source maps
Specialized Crates
oxc_isolated_declarations- TypeScript declaration file generationoxc_language_server- LSP server for editor integrationoxc_traverse- AST traversal utilitiesoxc_mangler- Identifier name mangling for minificationoxc_regular_expression- Regex parsing and analysis
Support Crates
oxc- Main crate that ties everything togetheroxc_ast_visit- Generated visitor traits for type-safe AST traversaloxc_macros- Procedural macros for code generation
Avoid editing any
generated subdirectories. These are automatically created by running just ast.apps/ - Application Binaries
Standalone applications built on top of the core crates:
apps/oxlint- Command-line linter with file discovery and parallel processingapps/oxfmt- Command-line formatter (seeapps/oxfmt/AGENTS.mdfor details)
napi/ - Node.js Bindings
NAPI (N-API) bindings for JavaScript integration:
napi/parser- Parser bindings for JavaScript toolingnapi/transform- Transformer bindings for bundlersnapi/minify- Minifier bindings
test/ directory using Vitest.
npm/ - NPM Packages
Published npm packages including the compiled NAPI binaries and configuration schemas.
tasks/ - Development Tools
Development infrastructure and tooling:
tasks/coverage- Conformance testing against Test262, Babel, TypeScripttasks/transform_conformance- Transformer-specific conformance teststasks/prettier_conformance- Formatter conformance against Prettiertasks/rulegen- Linter rule generatortasks/ast_tools- AST code generationtasks/benchmark- Performance benchmarkingtasks/minsize- Minifier size trackingtasks/website_*- Documentation generation for oxc.rs
editors/ - Editor Integrations
Editor extensions and plugins (e.g., VS Code extension).
Core Design Principles
1. Zero-Copy Architecture
Oxc uses an arena allocator (oxc_allocator) that enables zero-copy operations:
- No reference counting overhead (no
Rc/Arc) - Better cache locality
- Predictable performance
- Simple memory management
- Requires lifetime management
- AST tied to allocator lifetime
2. Visitor Pattern
AST traversal uses automatically generated visitor traits:oxc_ast_visit.
3. Distinct AST Types
Unlike ESTree, Oxc uses specific types instead of ambiguous nodes:BindingIdentifier- Variable declarations and bindingsIdentifierReference- Variable referencesIdentifierName- Property names and labels
4. Performance-First Design
- Arena allocation for memory efficiency
- Zero-copy strings using
CompactString - Parallel processing at file level
- Minimal allocations in hot paths
- No garbage collection for predictable performance
Development Workflow
Typical Development Flow
Working with Specific Components
Parser Development
Linter Development
Transformer Development
Formatter Development
Key Locations
Finding Code
- AST definitions:
crates/oxc_ast/src/ast/ - Linting rules:
crates/oxc_linter/src/rules/<plugin>/ - Parser entry:
crates/oxc_parser/src/lib.rs - Lexer:
crates/oxc_parser/src/lexer/ - Semantic analysis:
crates/oxc_semantic/src/ - Tests: Co-located with source in
tests/subdirectories
Configuration Files
.rustfmt.toml- Rust formatting configuration.clippy.toml- Clippy linter configurationjustfile- Development commandsCargo.toml- Workspace configurationoxlintrc.json- Oxlint configuration for the project itself
Conventions
Memory Management
- Use
oxc_allocator::Allocatorfor AST allocations - Use
Boxfor heap allocations outside the arena - Avoid
Rc/Arcin hot paths
Error Handling
- Use
oxc_diagnostics::OxcDiagnosticfor user-facing errors - Include source spans for diagnostic context
- Provide helpful error messages with suggestions
Performance
- Profile changes that affect hot paths
- Minimize allocations in loops
- Use
CompactStringfor short strings - Prefer borrowed data over cloning
Testing
- Write tests co-located with source code
- Use snapshot tests for complex output
- Run conformance tests for correctness
- See Testing Guide for details
Dependencies
Core Dependencies
- Rust: MSRV 1.91 (N-2 policy)
- Node.js: For NAPI bindings and npm packages
- pnpm: Node.js package manager
Key Rust Crates
compact_str- Efficient string handlingrustc-hash- Fast hash mapsserde- Serializationinsta- Snapshot testing
Next Steps
- Learn about Testing Infrastructure
- Learn how to Add Linter Rules
- Review Getting Started for setup
- Check the FAQ for common questions