Skip to content

Commit 2749353

Browse files
authored
docs: fill in contribute content (#432)
1 parent beb27f7 commit 2749353

File tree

9 files changed

+729
-30
lines changed

9 files changed

+729
-30
lines changed

src/docs/contribute/formatter.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,37 @@ outline: deep
55

66
# Formatter (Prettier)
77

8-
We are currently porting prettier to Oxc.
8+
We are currently porting Prettier and Biome Formatter to Oxc to create a high-performance, Prettier-compatible formatter.
9+
10+
## Architecture Overview
11+
12+
The Oxc formatter is built around the same core concepts as Prettier but with significant performance optimizations:
13+
14+
- **Document Model**: Uses Prettier and Biome's document IR (Intermediate Representation)
15+
- **Pretty Printing**: Implements Wadler's pretty printing algorithm
16+
- **AST Integration**: Leverages Oxc's fast parser for optimal performance
17+
18+
## Performance Considerations
19+
20+
### Optimization Strategies
21+
22+
- **Memory Arena**: AST allocated in bump allocator
23+
- **String Interning**: Reuse common strings
24+
- **Lazy Evaluation**: Defer expensive computations
25+
26+
## Current Challenges
27+
28+
### Technical Challenges
29+
30+
1. **Comment Handling**: Preserving comment placement and formatting
31+
2. **JavaScript Quirks**: Handling edge cases in JavaScript syntax
32+
3. **Performance vs Compatibility**: Balancing speed with exact Prettier output
33+
4. **Memory Management**: Efficient handling of large files
34+
35+
### Missing Features
36+
37+
- [ ] Plugin system compatibility
38+
- [ ] Configuration file support
39+
- [ ] Editor integrations
40+
- [ ] CLI tool
41+
- [ ] Language server protocol

src/docs/contribute/introduction.md

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,91 @@ title: Introduction
33
outline: deep
44
---
55

6-
# Introduction
6+
# Contributing to Oxc
77

8-
Thank you for your interest in contributing to Oxc!
8+
Thank you for your interest in contributing to Oxc! We're building the next generation of JavaScript tooling, and we'd love your help.
99

10-
Please check out our [good first issues](https://github.com/oxc-project/oxc/contribute) or ask for guidance on [Discord](https://discord.gg/9uXCAwqQZW).
10+
## Quick Start
1111

12-
We welcome and appreciate any form of contributions.
12+
The fastest way to get started is through our [good first issues](https://github.com/oxc-project/oxc/contribute). These are carefully selected tasks that are perfect for new contributors.
13+
14+
Need guidance? Join our [Discord community](https://discord.gg/9uXCAwqQZW) where our team and community members are happy to help.
15+
16+
## Ways to Contribute
17+
18+
We welcome and appreciate any form of contributions:
19+
20+
### 🐛 Bug Reports
21+
22+
- Report parsing errors or incorrect linting behavior
23+
- Share performance issues or regressions
24+
- Document edge cases we haven't considered
25+
26+
### 🚀 Feature Development
27+
28+
- Add new linting rules
29+
- Improve parser conformance
30+
- Enhance transformer capabilities
31+
- Build new tools in the Oxc ecosystem
32+
33+
### 📚 Documentation
34+
35+
- Improve getting started guides
36+
- Add examples and tutorials
37+
- Document architecture decisions
38+
- Translate content to other languages
39+
40+
### 🧪 Testing
41+
42+
- Add test cases from real-world codebases
43+
- Improve test coverage
44+
- Create performance benchmarks
45+
- Test against ecosystem projects
46+
47+
### 🔧 Infrastructure
48+
49+
- Improve build and CI systems
50+
- Enhance development tooling
51+
- Optimize performance critical paths
52+
- Maintain compatibility with other tools
53+
54+
### Understanding the Codebase
55+
56+
Oxc is organized into several crates:
57+
58+
- **`oxc_parser`**: High-performance JavaScript/TypeScript parser
59+
- **`oxc_linter`**: Fast linting engine with 500+ rules
60+
- **`oxc_transformer`**: TypeScript and JSX transformation
61+
- **`oxc_minifier`**: JavaScript minification (in development)
62+
- **`oxc_formatter`**: Code formatting (in development)
63+
64+
### Your First Contribution
65+
66+
1. **Browse Issues**: Look for issues labeled [`good first issue`](https://github.com/oxc-project/oxc/labels/good%20first%20issue)
67+
2. **Ask Questions**: Don't hesitate to ask for clarification on Discord or GitHub
68+
3. **Start Small**: Begin with documentation improvements or small bug fixes
69+
4. **Learn the Patterns**: Study existing code to understand our conventions
70+
71+
## Community
72+
73+
### Communication Channels
74+
75+
- **GitHub Discussions**: For design discussions and questions
76+
- **Discord**: Real-time chat with the team and community
77+
- **GitHub Issues**: Bug reports and feature requests
78+
- **Twitter**: Follow [@boshen_c](https://twitter.com/boshen_c) for updates
79+
80+
### Code of Conduct
81+
82+
We are committed to providing a welcoming and inclusive experience for everyone. Please read our [Code of Conduct](https://github.com/oxc-project/oxc/blob/main/CODE_OF_CONDUCT.md) before participating.
83+
84+
## Next Steps
85+
86+
Ready to contribute? Here are some great places to start:
87+
88+
- 📖 **Learn More**: Check out our [development guide](./development.md)
89+
- 🔍 **Find an Issue**: Browse our [good first issues](https://github.com/oxc-project/oxc/contribute)
90+
- 💬 **Join the Community**: Connect with us on [Discord](https://discord.gg/9uXCAwqQZW)
91+
- 🛠️ **Pick a Tool**: Dive into [parser](./parser.md), [linter](./linter.md), [transformer](./transformer.md), or [other tools](./formatter.md)
92+
93+
We can't wait to see what you'll build with us! 🚀

src/docs/contribute/minifier.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,65 @@ However, existing minifiers typically require a trade-off between compression qu
1313
You have to choose between the slowest for the best compression or the fastest for less compression.
1414
But what if we could develop a faster minifier without compromising on compression?
1515

16+
## Project Goals
17+
1618
We are actively working on a prototype that aims to achieve this goal,
1719
by porting all test cases from well-known minifiers such as [google-closure-compiler], [terser], [esbuild], and [tdewolff-minify].
1820

1921
Preliminary results indicate that we are on track to achieve our objectives.
2022
With the Oxc minifier, you can expect faster minification times without sacrificing compression quality.
2123

24+
### Target Performance
25+
26+
- **Speed**: faster than Terser, competitive with esbuild
27+
- **Compression**: Match or exceed Terser's compression ratio
28+
- **Correctness**: Pass all major minifier test suites
29+
30+
## Architecture Overview
31+
32+
### Design Principles
33+
34+
The Oxc minifier is built around several key principles:
35+
36+
1. **Semantic-Aware**: Uses semantic analysis to enable safe optimizations
37+
2. **Incremental**: Designed for incremental compilation workflows
38+
3. **Configurable**: Supports various optimization levels and targets
39+
4. **Correct**: Prioritizes correctness over aggressive optimization
40+
41+
## Current Status
42+
43+
### Implemented Features
44+
45+
-**Dead Code Elimination**: Remove unreachable code
46+
-**Constant Folding**: Evaluate constant expressions
47+
-**Tree Shaking**: Remove unused exports (basic)
48+
-**Variable Merging**: Merge variable declarations
49+
-**Statement Merging**: Combine compatible statements
50+
-**Name Mangling**: Shorten variable and function names
51+
-**Control Flow Optimization**: Simplify control structures
52+
-**Function Inlining**: Inline small functions
53+
-**Advanced Tree Shaking**: Cross-module optimization
54+
55+
### Performance Optimization
56+
57+
Key strategies for maintaining performance:
58+
59+
1. **Minimal AST Traversals**: Combine multiple optimizations in single passes
60+
2. **Efficient Data Structures**: Use arena allocation and compact representations
61+
3. **Early Termination**: Skip optimizations when no benefit is possible
62+
63+
## Resources
64+
65+
### Documentation
66+
67+
- [Minifier API Documentation](https://docs.rs/oxc_minifier)
68+
69+
### External References
70+
71+
- [Google Closure Compiler Optimizations](https://github.com/google/closure-compiler/wiki/JS-Modules)
72+
- [Terser Options](https://github.com/terser/terser#minify-options)
73+
- [esbuild Minification](https://esbuild.github.io/api/#minification)
74+
2275
[google-closure-compiler]: https://github.com/google/closure-compiler
2376
[terser]: https://github.com/terser/terser
2477
[esbuild]: https://github.com/evanw/esbuild

src/docs/contribute/parser.md

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,103 @@ outline: deep
55

66
# Parser
77

8-
We aim to be the fastest Rust-based ready-for-production parser.
8+
The Oxc parser is designed to be the fastest and most conformant JavaScript and TypeScript parser available. Contributing to the parser requires understanding both the implementation details and the extensive test infrastructure.
99

10-
## Conformance Tests
10+
## Architecture Overview
11+
12+
The parser follows a traditional compiler frontend architecture:
13+
14+
```
15+
Source Text → Lexer → Tokens → Parser → AST
16+
```
17+
18+
### Key Components
19+
20+
- **Lexer**: Tokenizes source text into structured tokens
21+
- **Parser**: Recursive descent parser that builds the AST
22+
- **AST**: Memory-efficient abstract syntax tree
23+
- **Error Recovery**: Advanced error handling and recovery
24+
- **Semantic Analysis**: Symbol resolution and scope management
25+
26+
### Design Goals
27+
28+
We aim to be the fastest Rust-based ready-for-production parser with:
29+
30+
- **Speed**: 3x faster than SWC, 5x faster than Biome
31+
- **Conformance**: 100% Test262 compliance, 99%+ Babel/TypeScript compatibility
32+
- **Memory Efficiency**: Arena-based allocation, minimal heap usage
33+
- **Error Quality**: Helpful error messages with recovery
34+
35+
## Development Workflow
36+
37+
### Setting Up
38+
39+
```bash
40+
# Run parser tests
41+
cargo test -p oxc_parser
42+
43+
# Run conformance tests
44+
just c # or `just coverage`
45+
```
46+
47+
### Project Structure
48+
49+
```
50+
crates/oxc_parser/
51+
├── src/
52+
│ ├── lib.rs # Public API
53+
│ ├── lexer/ # Tokenization
54+
│ ├── parser/ # Parsing logic
55+
│ ├── cursor.rs # Token stream management
56+
│ └── diagnostics.rs # Error handling
57+
├── tests/ # Unit tests
58+
└── examples/ # Usage examples
59+
```
60+
61+
### Core Parser Files
62+
63+
- **`parser/mod.rs`**: Main parser entry point
64+
- **`parser/statement.rs`**: Statement parsing
65+
- **`parser/expression.rs`**: Expression parsing
66+
- **`parser/typescript.rs`**: TypeScript-specific parsing
67+
- **`parser/jsx.rs`**: JSX parsing logic
68+
69+
## Conformance Testing
70+
71+
### Running Conformance Tests
1172

1273
```bash
1374
just c
1475
```
1576

16-
Aliased to `just coverage`, runs the following conformance test suites by using the conformance runner found in [tasks/coverage](https://github.com/oxc-project/oxc/tree/main/tasks/coverage).
77+
This runs conformance test suites using the runner in [tasks/coverage](https://github.com/oxc-project/oxc/tree/main/tasks/coverage):
1778

18-
### Test262
79+
### Test262 - ECMAScript Conformance
1980

2081
JavaScript has the [ECMAScript Test Suite](https://github.com/tc39/test262) called Test262.
2182
The goal of Test262 is to provide test material that covers every observable behavior specified in the specification.
83+
2284
Parser conformance uses the [parse phase tests](https://github.com/tc39/test262/blob/main/INTERPRETING.md#negative).
2385

24-
### Babel
86+
**Current Status**: `43765/43765 (100.00%)`
87+
88+
### Babel Parser Tests
2589

26-
When new language features are added to JavaScript, it is required to have them implemented by Babel,
27-
this means Babel has another set of [parser tests](https://github.com/babel/babel/tree/main/packages/babel-parser/test).
90+
When new language features are added to JavaScript, Babel implements them first.
91+
Babel has comprehensive [parser tests](https://github.com/babel/babel/tree/main/packages/babel-parser/test) for cutting-edge features.
2892

29-
### TypeScript
93+
**Current Status**: `2093/2101 (99.62%)`
94+
95+
### TypeScript Conformance
3096

3197
The TypeScript conformance tests can be found [here](https://github.com/microsoft/TypeScript/tree/main/tests/cases/conformance).
98+
99+
**Current Status**: `6470/6479 (99.86%)`
100+
101+
### Viewing Results
102+
103+
Test results are stored in snapshot files for tracking changes:
104+
105+
- [`parser_test262.snap`](https://github.com/oxc-project/oxc/blob/main/tasks/coverage/parser_test262.snap)
106+
- [`parser_babel.snap`](https://github.com/oxc-project/oxc/blob/main/tasks/coverage/parser_babel.snap)
107+
- [`parser_typescript.snap`](https://github.com/oxc-project/oxc/blob/main/tasks/coverage/parser_typescript.snap)

0 commit comments

Comments
 (0)