No description
Find a file
oxc-bot 64eb2cccb7
release: crates v0.27.0 (#5538)
## [0.27.0] - 2024-09-06

- bd820f9 semantic: [**BREAKING**] Remove
`SymbolTable::get_symbol_id_from_name` and
`SymbolTable::get_scope_id_from_name` (#5480) (overlookmotel)

- cba93f5 ast: [**BREAKING**] Add `ThisExpression` variants to
`JSXElementName` and `JSXMemberExpressionObject` (#5466) (overlookmotel)

- 87c5df2 ast: [**BREAKING**] Rename `Expression::without_parentheses`
(#5448) (overlookmotel)

### Features

- e8bdd12 allocator: Add `AsMut` impl for `Box` (#5515) (overlookmotel)
- 90facd3 ast: Add `ContentHash` trait; remove noop `Hash`
implementation from `Span` (#5451) (rzvxa)
- 23285f4 ast: Add `ContentEq` trait. (#5427) (rzvxa)
- 59abf27 ast, parser: Add `oxc_regular_expression` types to the parser
and AST. (#5256) (rzvxa)
- 68a1c01 ast_tools: Add dedicated `Derive` trait. (#5278) (rzvxa)
- c782916 codegen: Print `type_parameters` in `TaggedTemplateExpression`
(#5438) (Dunqing)
- 4cb63fe index: Impl rayon related to trait for IndexVec (#5421)
(IWANABETHATGUY)
- ba4b68c minifier: Remove parenthesized expression for dce (#5439)
(Boshen)
- ed8ab6d oxc: Conditional expose `oxc_cfg` in `oxc` crate (#5524)
(IWANABETHATGUY)
- 91b39c4 oxc_diagnostic: Impl DerefMut for OxcDiagnostic (#5474)
(IWANABETHATGUY)
- 10279f5 parser: Add syntax error for hyphen in `JSXMemberExpression`
`<Foo.bar-baz />` (#5440) (Boshen)
- 0f50b1e semantic: Check for initializers in ambient
`VariableDeclaration`s (#5463) (DonIsaac)
- 62f7fff semantic: Check for non-declared, non-abstract object
accessors without bodies (#5461) (DonIsaac)
- 5407143 semantic: Check for non-declared, non-abstract class accessors
without bodies (#5460) (DonIsaac)
- 052e94c semantic: Check for parameter properties in constructor
overloads (#5459) (DonIsaac)
- 32d4bbb transformer: Add `TransformOptions::enable_all` method (#5495)
(Boshen)
- c59d8b3 transformer: Support all /regex/ to `new RegExp` transforms
(#5387) (Dunqing)
- cedf7a4 xtask: Impl `as_ast_kind` method for each variant (#5491)
(IWANABETHATGUY)

### Bug Fixes

- 0df1d9d ast, codegen, linter: Panics in fixers. (#5431) (rzvxa)
- fce549e diagnostics: Ignore `Interrupted` and `BrokenPipe` errors
while printing (#5526) (Boshen)
- ea7a52f napi/transform: Fix test (Boshen)
- 9b984b3 regex: Panic on displaying surrogated `UnicodeEscape`
characters. (#5469) (rzvxa)
- 88b7ddb regular_expression: Handle unterminated character class
(#5523) (leaysgur)
- 7a797ac semantic: Incorrect reference when `MemberExpression` used in
`TSPropertySignature` (#5525) (Dunqing)
- d8b9909 semantic: `IdentifierReference` within `TSPropertySignature`
cannot reference type-only import binding (#5441) (Dunqing)
- 8f9627d transformer: RegExp transform do not transform invalid regexps
(#5494) (overlookmotel)
- 2060efc transformer: RegExp transform don't transform all RegExps
(#5486) (overlookmotel)
- cfe5497 transformer: Do not create double reference in JSX transform
(#5414) (overlookmotel)
- 0617249 transformer/nullish-coalescing-operator: Incorrect reference
flags (#5408) (Dunqing)
- 0eb32a6 traverse: Invalid variable name generated by
`generate_uid_based_on_node` (#5407) (Dunqing)- b96bea4 Add back
lifetime (#5507) (IWANABETHATGUY)

### Performance

- bfabd8f syntax: Further optimize `is_identifier_name` (#5426)
(overlookmotel)
- aeda84f syntax: Optimize `is_identifier_name` (#5425) (overlookmotel)
- ed8937e transformer: Memoize rope instance (#5518) (Dunqing)
- bfab091 transformer: Store needed options only on `RegExp` (#5484)
(overlookmotel)
- b4765af transformer: Pre-calculate if unsupported patterns in RegExp
transform (#5483) (overlookmotel)
- 182ab91 transformer: Pre-calculate unsupported flags in RegExp
transform (#5482) (overlookmotel)

### Documentation

- 64db1b4 ast: Clarify docs for `RegExpPattern` (#5497) (overlookmotel)
- 3f204a9 span: Update docs about `ContentEq` `Vec` comparison speed
(#5478) (overlookmotel)- 00511fd Use `oxc_index` instead of `index_vec`
in doc comments (#5423) (IWANABETHATGUY)

### Refactor

- 9f6e0ed ast: Simplify `ContentEq` trait definition. (#5468) (rzvxa)
- a43e951 ast: Use loop instead of recursion (#5447) (overlookmotel)
- 2224cc4 ast: Renumber `JSXMemberExpressionObject` discriminants
(#5464) (overlookmotel)
- a952c47 ast: Use loop not recursion (#5449) (overlookmotel)
- d9d7e7c ast: Remove `IdentifierName` from `TSThisParameter` (#5327)
(overlookmotel)
- ccc8a27 ast, ast_tools: Use full method path for generated derives
trait calls. (#5462) (rzvxa)
- fdb8857 linter: Use "parsed pattern" in `no_div_regex` rule. (#5417)
(rzvxa)
- e7bd49d regular_expression: Correct typo (#5429) (overlookmotel)
- e4ed41d semantic: Change the reference flag to `ReferenceFlags::Type`
if it is used within a `TSTypeQuery` (#5444) (Dunqing)
- 94a6ac6 span: Use `Hasher` from `std` (#5476) (overlookmotel)
- b47aca0 syntax: Use `generate_derive` for `CloneIn` in types outside
of `oxc_ast` crate. (#5280) (rzvxa)
- a96866d transformer: Re-order imports (#5499) (overlookmotel)
- 6abde0a transformer: Clarify match in RegExp transform (#5498)
(overlookmotel)
- 09c522a transformer: RegExp transform report pattern parsing errors
(#5496) (overlookmotel)
- dd19823 transformer: RegExp transform do not take ownership of
`Pattern` then reallocate it (#5492) (overlookmotel)
- 2514cc9 transformer/react: Move all entry points to implementation of
Traverse trait (#5473) (Dunqing)
- c984219 transformer/typescript: Move all entry points to
implementation of Traverse trait (#5422) (Dunqing)

### Styling

- 2a43fa4 linter: Introduce the writing style from PR #5491 and reduce
the if nesting (#5512) (dalaoshu)

### Testing

- 340b535 linter/no-unused-vars: Arrow functions in tagged templates
(#5510) (Don Isaac)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-06 19:06:29 +08:00
.cargo ci: run conformance with debug assertions (#4386) 2024-07-21 20:40:50 +08:00
.github refactor(ast_tools): add some minimal logging. (#5519) 2024-09-06 06:19:50 +00:00
.vscode chore: add default VSCode build task (#4822) 2024-08-11 23:05:27 +08:00
apps/oxlint feat(linter/node): implement no-exports-assign (#5370) 2024-09-03 07:53:14 -04:00
crates release: crates v0.27.0 (#5538) 2024-09-06 19:06:29 +08:00
editors Release oxlint v0.9.2 (#5401) 2024-09-02 20:30:22 +08:00
napi release: crates v0.27.0 (#5538) 2024-09-06 19:06:29 +08:00
npm release: crates v0.27.0 (#5538) 2024-09-06 19:06:29 +08:00
tasks fix(semantic): incorrect reference when MemberExpression used in TSPropertySignature (#5525) 2024-09-06 06:24:45 +00:00
wasm/parser release: crates v0.27.0 (#5538) 2024-09-06 19:06:29 +08: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
.gitignore chore: remove .idea from .gitignore (#4496) 2024-07-26 23:59:24 +00:00
.ignore
.node-version chore: bump node to v22.7.0 (#5388) 2024-09-01 21:52:01 +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(regex_parser): Implement RegExp parser (#3824) 2024-08-20 02:19:24 +00:00
Cargo.lock release: crates v0.27.0 (#5538) 2024-09-06 19:06:29 +08:00
Cargo.toml release: crates v0.27.0 (#5538) 2024-09-06 19:06:29 +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 chore: format Cross.toml 2024-09-06 18:51:08 +08:00
deny.toml chore: update deny.toml 2024-08-12 10:12:03 +08:00
justfile chore(justfile): bundle wasm with different flag (#5433) 2024-09-04 13:30:48 +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: add scopes_for_breaking_change to oxc_release.toml 2024-08-29 11:02:48 +08:00
package.json ci: add napi tests (#5419) 2024-09-03 12:24:58 +08:00
pnpm-lock.yaml ci: fix broken benchmark (#5424) 2024-09-03 18:21:39 +08:00
pnpm-workspace.yaml ci: fix broken benchmark (#5424) 2024-09-03 18:21:39 +08:00
README.md chore(README): update playground link 2024-09-04 12:18:24 +08:00
rust-toolchain.toml chore(deps): update dependency rust to v1.81.0 (#5502) 2024-09-05 16:57:47 +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, transformer, 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 93 rules turned on by default (out of 400+ 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

A transformer is responsible for turning higher versions of ECMAScript to a lower version that can be used in older browsers.

TypeScript and React transforms are complete. See Milestone 2 for current goals.

oxc-transform can be used for experimentation.

🔸 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.


🧪Test Infrastructure

In Oxc, correctness and reliability are taken extremely seriously.

We spend half of our time on strengthening the test infrastructure to prevent problems from propagating to downstream tools.

Test Infrastructure documents our test procedures:

  • Conformance suite on Test262, Babel, TypeScript
  • Lots of fuzzing
  • Linter snapshot diagnostics
  • oxlint ecosystem ci
  • Idempotency testing
  • Code coverage
  • End to end 3000 top npm packages

✍️ 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.