No description
Find a file
oxc-bot e02bac357a
Release crates v0.23.0 (#4595)
## [0.23.0] - 2024-08-01

- 27fd062 sourcemap: [**BREAKING**] Avoid passing `Result`s (#4541)
(overlookmotel)

### Features

- a558492 codegen: Implement `BinaryExpressionVisitor` (#4548) (Boshen)
- 7446e98 codegen: Align more esbuild implementations (#4510) (Boshen)
- 35654e6 codegen: Align operator precedence with esbuild (#4509)
(Boshen)
- b952942 linter: Add eslint/no-unused-vars ( attempt 3.2) (#4445)
(DonIsaac)
- 85e8418 linter: Add react/jsx-curly-brace-presence (#3949) (Don Isaac)
- cf1854b semantic: Remove `ReferenceFlags::Value` from non-type-only
exports that referenced type binding (#4511) (Dunqing)

### Bug Fixes

- b58ed80 codegen: Enable more test cases (#4585) (Boshen)
- 6a94e3f codegen: Fixes for esbuild test cases (#4503) (Boshen)
- d5c4b19 parser: Fix enum member parsing (#4543) (DonIsaac)

### Performance

- 4c6d19d allocator: Use capacity hint (#4584) (Luca Bruno)
- 7585e16 linter: Remove allocations for string comparisons (#4570)
(DonIsaac)
- 55a8763 parser: Faster decoding unicode escapes in identifiers (#4579)
(overlookmotel)
- ae1d38f parser: Fast path for ASCII when checking char after numeric
literal (#4577) (overlookmotel)
- 56ae615 parser: Make not at EOF the hot path in `Source` methods
(#4576) (overlookmotel)
- 25679e6 parser: Optimize `Lexer::hex_digit` (#4572) (overlookmotel)
- bb33bcc parser: Speed up lexing non-decimal numbers (#4571)
(overlookmotel)
- ab8509e parser: Use `-` not `saturating_sub` (#4561) (overlookmotel)
- c9c38a1 parser: Support peeking over bytes (#4304) (lucab)
- 0870ee1 parser: Get and check lookahead token (#4534) (lucab)
- d00014e sourcemap: Elide bounds checks in VLQ encoding (#4583)
(overlookmotel)
- 1fd9dd0 sourcemap: Use simd to escape JSON string (#4487)
(Brooooooklyn)

### Documentation

- 0914e47 ast: Add doc comments to literal nodes (#4551) (DonIsaac)
- c6a11be ast: Auto-generate doc comments for AstBuilder methods (#4471)
(DonIsaac)

### Refactor

- e68ed62 parser: Convert lexer byte handler for `|` to a single match
(#4575) (overlookmotel)
- bba824b parser: Convert `Lexer::read_minus` to a single match (#4574)
(overlookmotel)
- ef5418a parser: Convert `Lexer::read_left_angle` to a single match
(#4573) (overlookmotel)
- 9e5be78 parser: Add `Lexer::consume_2_chars` (#4569) (overlookmotel)
- 649913e parser: Extract `u8` not `&u8` when iterating over bytes
(#4568) (overlookmotel)
- 59f00c0 parser: Rename function (#4566) (overlookmotel)
- 8e3e910 parser: Rename vars (#4565) (overlookmotel)
- 0c0601f parser: Rename function (#4564) (overlookmotel)
- 0acc4a7 parser: Fetch 2 bytes in `?` byte handler (#4563)
(overlookmotel)
- 565eccf parser: Shorten lexer code (#4562) (overlookmotel)
- 148bdb5 parser: Adjust function inlining (#4530) (overlookmotel)
- 16c7b98 semantic: Move CatchClause scope binding logic to
visit_block_statement (#4505) (Dunqing)
- d6974d4 semantic: `AstNodeParentIter` fetch nodes lazily (#4533)
(overlookmotel)
- d914b14 semantic: Reusing the same reference (#4529) (Dunqing)
- 7b5e1f5 semantic: Use `is_empty()` instead of `len() == 0` (#4532)
(overlookmotel)
- 9db4259 semantic: Inline trivial methods (#4531) (overlookmotel)
- 7c42ffc sourcemap: Align Base64 chars lookup table to cache line
(#4535) (overlookmotel)
- 96602bf transformer/typescript: Determine whether to remove
`ExportSpeicifer` by `ReferenceFlags` (#4513) (Dunqing)
- e6a8af6 traverse: Speed up tests (#4538) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-01 16:55:41 +08:00
.cargo ci: run conformance with debug assertions (#4386) 2024-07-21 20:40:50 +08:00
.github ci: test crates on wasmtime (#4547) 2024-08-01 06:23:35 +08:00
.vscode chore: add some useful informantion log (#1912) 2024-01-06 22:30:01 +08:00
apps/oxlint fix(linter): change no-unused-vars to nursery (#4588) 2024-07-31 16:21:23 +00:00
crates Release crates v0.23.0 (#4595) 2024-08-01 16:55:41 +08:00
editors/vscode chore(deps): update dependency @types/node to v22 (#4523) 2024-07-29 01:21:43 +00:00
fuzz chore: turn off doctest for all [[bin]] 2024-07-14 16:55:19 +08:00
napi Release crates v0.23.0 (#4595) 2024-08-01 16:55:41 +08:00
npm Release crates v0.23.0 (#4595) 2024-08-01 16:55:41 +08:00
tasks feat(codegen): implement BinaryExpressionVisitor (#4548) 2024-07-31 12:44:19 +00:00
wasm/parser Release crates v0.23.0 (#4595) 2024-08-01 16:55:41 +08:00
website chore(deps): update website npm packages (#4521) 2024-07-29 00:05:23 +00:00
.clippy.toml chore(deps): update dependency rust to v1.80.0 (#4474) 2024-07-26 01:26:44 +00:00
.editorconfig chore: remove trailing whitespaces for all files; add .editorconfig (#3639) 2024-06-12 15:47:26 +08:00
.git-blame-ignore-revs chore: update .git-blame-ignore-revs 2023-07-28 13:57:29 +08:00
.gitignore chore: remove .idea from .gitignore (#4496) 2024-07-26 23:59:24 +00:00
.ignore chore: add just watch command for overcoming cargo-watch being slow 2023-05-16 13:22:42 +08:00
.node-version ci: use node-version-file (#3607) 2024-06-10 22:06:09 +08:00
.rustfmt.toml chore: move rustfmt.toml -> .rustfmt.toml 2024-05-12 13:14:50 +08:00
.taplo.toml chore: add .cargo/config.toml to taplo 2024-07-21 20:37:48 +08:00
.typos.toml feat(linter): add eslint/no-unused-vars ( attempt 3.2) (#4445) 2024-07-31 03:22:16 +00:00
Cargo.lock Release crates v0.23.0 (#4595) 2024-08-01 16:55:41 +08:00
Cargo.toml Release crates v0.23.0 (#4595) 2024-08-01 16:55:41 +08:00
CHANGELOG.md chore: update CHANGELOG.md 2024-06-06 20:24:19 +08:00
cliff.toml chore: cliff.toml features_always_bump_minor = false 2024-06-14 14:42:20 +08:00
CONTRIBUTING.md chore: change website url to https://oxc.rs 2024-06-05 22:05:08 +08:00
Cross.toml ci: passthrough CI env variable for cross build 2024-06-27 21:11:16 +08:00
deny.toml chore: format top level toml files 2024-06-04 16:05:08 +08:00
justfile feat(linter): Add eslint-plugin-promise rules: avoid-new, no-new-statics, params-names (#4293) 2024-07-17 09:21:20 +08:00
LICENSE Change license holder to @boshen 2023-11-10 14:26:11 +08:00
MAINTENANCE.md chore: update MAINTENANCE.md 2024-06-19 20:13:12 +08:00
oxc_release.toml chore: clean up unused deps 2024-06-30 19:04:44 +08:00
README.md chore: update logo and asset links 2024-07-14 13:38:35 +08:00
rust-toolchain.toml chore(deps): update dependency rust to v1.80.0 (#4474) 2024-07-26 01:26:44 +00:00
THIRD-PARTY-LICENSE chore(index): fork index_vec crate. (#3092) 2024-04-25 06:09:53 +00:00

OXC Logo

MIT licensed Build Status Code Coverage CodSpeed Badge Sponsors

Discord chat Playground Website

Oxc

The Oxidation Compiler is creating a collection of high-performance tools for JavaScript and TypeScript.

Oxc is building a parser, linter, formatter, transpiler, minifier, resolver ... all written in Rust.

See more at oxc.rs!

🙋Who's using Oxc?

Linter Quick Start

The linter is ready to catch mistakes for you. It comes with 91 rules turned on by default (out of 340+ in total) and no configuration is required.

To get started, run oxlint or via npx:

npx oxlint@latest

To give you an idea of its capabilities, here is an example from the vscode repository, which finishes linting 4800+ files in 0.7 seconds.

Performance

  • The parser aims to be the fastest Rust-based ready-for-production parser.
  • The linter is more than 50 times faster than ESLint, and scales with the number of CPU cores.

⌨️ Rust, Node.js and Wasm Usage

Rust

Individual crates are published, you may use them to build your own JavaScript tools.

  • The umbrella crate oxc exports all public crates from this repository.
  • The AST and parser crates oxc_ast and oxc_parser are production ready.
  • The resolver crate oxc_resolver for module resolution is also production ready.
  • Example usages of these crates can be found in their respective crates/*/examples directory.

While Rust has gained a reputation for its comparatively slower compilation speed, we have dedicated significant effort to fine-tune the Rust compilation speed. Our aim is to minimize any impact on your development workflow, ensuring that developing your own Oxc based tools remains a smooth and efficient experience.

This is demonstrated by our CI runs, where warm runs complete in 3 minutes.

Node.js

Wasm


🎯 Tools

🔸 AST and Parser

Oxc maintains its own AST and parser, which is by far the fastest and most conformant JavaScript and TypeScript (including JSX and TSX) parser written in Rust.

As the parser often represents a key performance bottleneck in JavaScript tooling, any minor improvements can have a cascading effect on our downstream tools. By developing our parser, we have the opportunity to explore and implement well-researched performance techniques.

While many existing JavaScript tools rely on estree as their AST specification, a notable drawback is its abundance of ambiguous nodes. This ambiguity often leads to confusion during development with estree.

The Oxc AST differs slightly from the estree AST by removing ambiguous nodes and introducing distinct types. For example, instead of using a generic estree Identifier, the Oxc AST provides specific types such as BindingIdentifier, IdentifierReference, and IdentifierName. This clear distinction greatly enhances the development experience by aligning more closely with the ECMAScript specification.

🏆 Parser Performance

Our benchmark reveals that the Oxc parser surpasses the speed of the swc parser by approximately 3 times and the Biome parser by 5 times.

How is it so fast?
  • AST is allocated in a memory arena (bumpalo) for fast AST memory allocation and deallocation.
  • Short strings are inlined by CompactString.
  • No other heap allocations are done except the above two.
  • Scope binding, symbol resolution and some syntax errors are not done in the parser, they are delegated to the semantic analyzer.

🔸 Linter

The linter embraces convention over configuration, eliminating the need for extensive configuration and plugin setup. Unlike other linters like ESLint, which often require intricate configurations and plugin installations (e.g. @typescript-eslint), our linter only requires a single command that you can immediately run on your codebase:

npx oxlint@latest

🏆 Linter Performance

The linter is 50 - 100 times faster than ESLint depending on the number of rules and number of CPU cores used. It completes in less than a second for most codebases with a few hundred files and completes in a few seconds for larger monorepos. See bench-javascript-linter for details.

As an upside, the binary is approximately 5MB, whereas ESLint and its associated plugin dependencies can easily exceed 100.

You may also download the linter binary from the latest release tag as a standalone binary, this lets you run the linter without a Node.js installation in your CI.

How is it so fast?
  • Oxc parser is used.
  • AST visit is a fast operation due to linear memory scan from the memory arena.
  • Files are linted in a multi-threaded environment, so scales with the total number of CPU cores.
  • Every single lint rule is tuned for performance.

🔸 Resolver

Module resolution plays a crucial role in JavaScript tooling, especially for tasks like multi-file analysis or bundling. However, it can often become a performance bottleneck. To address this, we developed oxc_resolver.

The resolver is production-ready and is currently being used in Rolldown. Usage and examples can be found in its own repository.

🔸 Transformer (Transpiler)

A transformer is responsible for turning higher versions of ECMAScript to a lower version that can be used in older browsers. We are currently focusing on the architecture. See Milestone 1 for details.

🔸 Isolated Declarations

TypeScript Isolated Declarations Emit without using the TypeScript compiler.

Our benchmark indications that our implementation is at least 20 times faster than the TypeScript compiler.

The npm package or crate can be used for this task.

🔸 Minifier

JavaScript minification plays a crucial role in optimizing website performance as it reduces the amount of data sent to users, resulting in faster page loads. This holds tremendous economic value, particularly for e-commerce websites, where every second can equate to millions of dollars.

However, existing minifiers typically require a trade-off between compression quality and speed. You have to choose between the slowest for the best compression or the fastest for less compression. But what if we could develop a faster minifier without compromising on compression?

We are actively working on a prototype that aims to achieve this goal, by porting all test cases from well-known minifiers such as google-closure-compiler, terser, esbuild, and tdewolff-minify.

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

🔸 Formatter

While prettier has established itself as the de facto code formatter for JavaScript, there is a significant demand in the developer community for a less opinionated alternative. Recognizing this need, our ambition is to undertake research and development to create a new JavaScript formatter that offers increased flexibility and customization options.

The prototype is currently work in progress.


✍️ Contribute

See CONTRIBUTING.md for guidance.

Check out some of the good first issues or ask us on Discord.

If you are unable to contribute by code, you can still participate by:

📚 Learning Resources

🤝 Credits

This project was incubated with the assistance of these exceptional mentors and their projects:

Special thanks go to

❤ Who's Sponsoring Oxc?

My sponsors

📖 License

Oxc is free and open-source software licensed under the MIT License.

Oxc ports or copies code from other open source projects, their licenses are listed in Third-party library licenses.