Formatter (Prettier) ​
We are currently porting Prettier and Biome Formatter to Oxc to create a high-performance, Prettier-compatible formatter.
Architecture Overview ​
The Oxc formatter is built around the same core concepts as Prettier but with significant performance optimizations:
- Document Model: Uses Prettier and Biome's document IR (Intermediate Representation)
- Pretty Printing: Implements Wadler's pretty printing algorithm
- AST Integration: Leverages Oxc's fast parser for optimal performance
Performance Considerations ​
Optimization Strategies ​
- Memory Arena: AST allocated in bump allocator
- String Interning: Reuse common strings
- Lazy Evaluation: Defer expensive computations
Current Challenges ​
Technical Challenges ​
- Comment Handling: Preserving comment placement and formatting
- JavaScript Quirks: Handling edge cases in JavaScript syntax
- Performance vs Compatibility: Balancing speed with exact Prettier output
- Memory Management: Efficient handling of large files
Missing Features ​
- [ ] Plugin system compatibility
- [ ] Configuration file support
- [ ] Editor integrations
- [ ] CLI tool
- [ ] Language server protocol