Commit Graph

102 Commits

Author SHA1 Message Date
overlookmotel 6365db964b test(lexer): enable oxc_lexer conformance tests on all platforms (#26263)
`oxc_lexer` has 2 implementations:

1\. SIMD-based on x86_64 with AVX2.
2\. Scalar/SWAR fallback which works on all platforms.

Both produce the same output.

This PR enables running the lexer conformance on either implementation. Which implementation is tested depends on what build flags are passed to `cargo coverage`.

It turns out that it's possible to test the SIMD implementation on Mac by compiling as x86_64, and running it under Rosetta 2.

This PR also adds `just` recipes to run tests and conformance on either implementation:

- `just test-lexer`
- `just test-lexer-simd`
- `just conformance-lexer`
- `just conformance-lexer-simd`

These commands should work correctly on any of Linux x86, Windows x86, Mac aarch64.
2026-09-03 10:59:05 +00:00
Boshen baf022d74d refactor(ast)!: remove old AstBuilder methods (#24563)
Closes the migration tracked in #23043.

The new builder API (methods on the AST types themselves) has been in place for a while, all Oxc crates are migrated, and every crate which uses `AstBuilder` already enables `disable_old_builder` in its tests. The module docs said "after a few weeks, we will remove `AstBuilder`'s own methods entirely" — this does that.

## What's removed

- `crates/oxc_ast/src/generated/ast_builder.rs` and `builder/methods.rs` — `AstBuilder`'s own node and primitive constructors.
- `AstBuilderGenerator`, which produced the former.
- The `disable_old_builder` Cargo feature, plus the dev-dependency hacks it required across 33 manifests. Eight crates depended on `oxc_ast` *purely* to turn the feature on; those deps and their `cargo-shear` ignore entries are gone too.

## One thing worth reviewing

`AstBuilderGenerator` owned the `#[builder(default)]` / `#[builder(skip)]` attr registration that `BuilderMethodsGenerator` only *reads* — its doc comment said as much. Deleting it naively would have silently dropped `skip`/`default` handling for the 12 AST types using those attrs, so `attrs()` and `parse_attr()` move to `BuilderMethodsGenerator`.

The evidence this was faithful: after regenerating, `builder_methods.rs` and every other generated file are **byte-identical**. The only generated change in the diff is the deletion.

## Breaking changes

- `AstBuilder`'s own methods are gone. Use the AST type methods: `Statement::new_expression_statement(span, expr, &builder)` instead of `builder.statement_expression(span, expr)`.
- `AstBuilder` is no longer `Copy`/`Clone`, and its `allocator` field is private — use the `allocator` method from `GetAllocator`.
- `AstBuilder` and `NONE` are no longer re-exported from the crate root; import them from `oxc_ast::builder`. (The `disable_old_builder` feature already gated these off, so nothing in-tree used the root path.)
- The `disable_old_builder` feature no longer exists — remove it from any manifest that sets it.

A migration note covering all of the above is in `crates/oxc_ast/src/builder/mod.rs`.

---

Implemented with AI assistance (Claude Code); design, review, and verification driven by the author per the repo AI-usage policy.
2026-07-21 15:22:46 +00:00
Shanon Jackson 6ab439a902 feat(lexer): add oxc_lexer, a unfused SIMD lexer for JS/TS/TSX (#24172)
Adds the x86_64 version of my Research `SIMD For Context Sensitive
Languages`.
(CPB = Cycles per byte)
- Adds new create crates/oxc_lexer; Which eventually lead into an
unfused parser design inside oxc_parser
- Fully test262 compliant JS standalone Lexer; SIMD used has
counterparts on every platform.
- Performs at 2.5CPB on checker.js on my ZEN 3 CPU; or around 1.5-1.75
gbs (3.8GHz).
- Across aarch64, + other platforms performance will hold which I've
seen in my POCs but those targets will come later.
- Supports JSX/TS options, Which don't have much impact on overall perf
results.

------

The expected results for seeing this work through [including on parser
side on oxc_parser]
1. P95 improvements of 80-100% over current `oxc_parser`; 12-18% of this
will come from the unfused contract where JS grammar specifically loves
being able to see 'ahead' into `kinds` in various places. The rest comes
from the perf improvements to the lexer itself and some wins that will
come inside the parser from work now done in the lexer.
2026-07-08 18:07:33 +01:00
overlookmotel 85a6853e0b fix(tasks): enable disable_old_builder Cargo feature for oxc_ast crate for all tasks (#23885)
Part of #23043.

We don't enable `oxc_ast`'s `disable_old_builder` Cargo feature in any of our published crates, or crates that are depended on by published crates.

Tasks are private to the repo, so enable this feature on them, to ensure no usage of legacy `AstBuilder` methods sneak in during the transition period before we delete these methods.
2026-06-28 12:13:17 +00:00
leaysgur c323187f37 refactor(formatter): Split oxc_formatter and oxc_formatter_core (#22611)
Split `oxc_formatter` into:

- `oxc_formatter(_js)`: JS/TS specific formatter, comment handling, sortImports, jsdoc, etc
- `oxc_formatter_core`: Language agnostic IR, printer, etc

The naming convention is different from Biome or Ruff (they do not have `_core`, and `_formatter` is equivalent to the core), but this is because in Oxc, items without `_js` are the default.

As a basic task, I have added `Context` as a generic to all relevant parts to ensure support for multiple languages.

There might still be other components that could be refactored into the core, but I would like to finish them as I implement support for other languages.

Also moved some shared utilities to the core in advance.
2026-05-29 00:49:49 +00:00
camc314 9e11dc63a0 feat(parser,estree,coverage): collect tokens in parser and convert to ESTree format (#19497)
Implement a `collect_tokens` option for parser. When enabled, the parser stores all tokens produced during parsing in a `Vec`. Implement serializing the tokens to ESTree format.

Currently this is not hooked up to NAPI parser or linter. That happens in a later PR in this stack (#19498).

Serialization of tokens implementation is in new `oxc_estree_tokens` crate. Unfortunately it can't go in existing `oxc_estree` crate because `oxc_ast` depends on `oxc_estree`, and the tokens serialization code requires AST types - which would be a circular dependency. We may be able to move it into another crate (parser?) later on.
2026-02-24 02:35:12 +00:00
camc314 8e936717d9 refactor(tasks/coverage): use tasks_common for printing diff (#19510)
This makes the diffs more readable by including the surrouding lines.,

This aids debugging and makes the changes easier to comprehend
2026-02-18 01:32:30 +00:00
Boshen be4f3d7f25 perf(coverage): extract path conversion and avoid unnecessary clones (#18921)
- Extract `path.to_string_lossy()` before error loops to avoid repeated conversions
- Use `as_str()` instead of `clone()` in BaselineFile::print()
- Remove unnecessary clone in BaselineFile::snapshot()
- Use `map_or_else` to avoid allocating "Panicked" string in success paths

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 09:17:43 +00:00
Dunqing 4d97ba3952 chore(tasks): unify printing differences for mismatch code (#18441)
Instead of implementing printing diffs everywhere, use a unified method to make the code cleaner and maintain consistency.
2026-01-26 05:16:44 +00:00
Boshen 87684d7470 perf(coverage): simplify architecture and cache test data upfront (#18478)
Local: 2.4x faster (31s → 13s)
CI: saved 50s
2026-01-24 11:09:09 +00:00
Boshen 423c27e260 test(rust): reenable lib tests that only run for code coverage 2026-01-01 11:12:14 +08:00
Boshen 8f98fa0d4e test(rust): disable empty test and doctest targets (#17409)
## Summary

- Disable `test = false` and `doctest = false` for crates that have no tests
- Reduces CI noise from "0 passed; 0 failed" output
- Saves compilation time for empty test targets

**Affected crates:**
- `oxc_ast_macros` - lib test
- `oxc_language_server` - bin test, lib doctest
- `oxc_napi` - lib test
- `oxc_syntax` - lib doctest
- `oxc_compat_data` - bin test
- `oxc_coverage` - lib test
- `oxc_linter_codegen` - bin test
- `oxc_prettier_conformance` - lib test
- `oxc_transform_conformance` - lib test
- `vscode_docs` - bin test
- `website_common` - lib test, lib doctest

## Test plan

- [x] `cargo test` passes with no empty test suites

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2025-12-28 11:44:19 +00:00
sapphi-red ee035b49c6 test(tasks/coverage/typescript): collect more error files (#15496)
Improved the error file collection logic to pick up files like `importMeta(module=system,target=es5).errors.txt`​. Also added support for `preserveconstenums`​ and `usedefineforclassfields`.
2025-11-10 04:36:10 +00:00
Yuji Sugiura 70749bb20e refactor(coverage/parser_typescript): Improve should_fail check by extracting diagnostic codes from .errors.txt (#11858)
Part of #11582 

- 👉🏻 Check error codes in coverage tests
- Fill more error codes 
- Dump currently reviewed error codes somewhere
2025-06-23 15:53:17 +08:00
overlookmotel 53d1a851dd test(ast/estree): do not ignore repeated fields in TS-ESTree AST (#11501)
#11500 fixed the duplicate fields in TS-ESTree AST. TS-ESTree conformance no longer needs to ignore duplicate fields.
2025-06-05 15:54:56 +00:00
overlookmotel a05361e4a2 test(ast/estree): check span offsets are converted in ascending order in ESTree conformance tests (#10887)
Add a Cargo feature `conformance` to `oxc_ast_visit` crate.

When this feature is enabled, it exposes a method `Utf8ToUtf16::convert_program_with_ascending_order_checks` which panics if span offsets are converted out of order.

Use this feature and method in ESTree conformance tests. This ensures:

1. `Utf8ToUtf16Converter` visitor is functioning as intended.
2. All AST types have their fields ordered in order they appear in source code.
2025-05-14 01:22:55 +00:00
overlookmotel 50bddbb9e0 test(ast/estree): skip tests related to hashbangs (#10602)
We intentionally add a `hashbang` field to `Program`, which isn't present in ESTree or TS-ESTree AST. This causes some tests to erroneously fail. So skip them.

#10669 adds hashbangs to `comments` in ESTree AST to align with Acorn, and adds tests relating to hashbangs to `napi/parser`, so our test coverage for hashbangs is maintained, despite skipping these tests.
2025-04-28 14:33:49 +00:00
Boshen d82dff91c8 feat(formatter): new implementation based on biome formatter (#10108)
Part of #5068, suggested by @ematipico and @MichaReiser, where @leaysgur
and I explored using biome formatter as the base and made a success. All
credits to the old Rome and the new Biome team.

This PR is in a boilerplate state where some of the functions are marked
as `todo!()`.

I also made the following changes:

* changed the base to be less generic, removed the `Language` and
`Context` generics
* expanded the formatter lifetime to include an `'ast` lifetime
* added access to the source text and comments
* added a mechanism for tracking and accessing parent ast nodes (done by
our codegen)
* removed most of the unit tests because they no longer compile
* removed the `oxc_prettier` crate
2025-03-30 16:54:37 +08:00
Boshen be62d38398 refactor(rust): remove usages of lazy_static (#10007) 2025-03-24 08:18:11 +00:00
Boshen 6432707052 refactor(rust): use lazy-regex (#10004) 2025-03-24 08:03:00 +00:00
overlookmotel 38f81af340 fix(ast/estree): order fields same as Acorn (#9128)
Use the `#[estree(field_order(...))]` attribute introduced in #9127 to re-order fields in the ESTree AST so they match Acorn exactly.

Make the ESTree conformance tester stricter - it now errors on incorrect field order.

All conformance tests still passing after this PR.
2025-02-15 12:47:19 +08:00
overlookmotel 48abd0b379 test(ast/estree): ESTree conformance tester handle deeply nested JSON (#9068)
Fix ESTree conformance tester, to handle deeply nested JSON. Previously some tests were failing only because the AST's depth exceeded `serde_json`'s default recursion limit.
2025-02-12 13:39:35 +00:00
翠 / green 3ba0b5316d chore(tasks/coverage): fix test262 cases to run on windows (#8358)
`skip_test_path` was not working on windows because the path included
`\\`.
2025-01-09 10:48:37 +08:00
Boshen 348d4f451a feat(sourcemap): move oxc_sourcemap to github.com/oxc-project/oxc-sourcemap (#7604)
It's mostly stable so we can v1.0.0 it.

And we will create cyclic dependency with StringWizard soon.
2024-12-03 11:59:43 +00:00
Boshen ffa3945465 chore(coverage): ignore v8 failed cases from runtime.snap (#6780) 2024-10-22 16:21:42 +00:00
overlookmotel e19deaa102 ci(transformer): move post-transform checker to tasks crate (#6288)
Move post-transform checker into a `tasks` crate. It doesn't feel like it belongs in `oxc_semantic`. It also feels like too heavy a lump of code to put in `tasks/common`.
2024-10-05 14:48:37 +00:00
camchenry 02d5637dbc perf(ast-tools): use FxHashMap over std::collections::HashMap (#5997) 2024-09-23 18:28:54 +00:00
overlookmotel eadffb900e test(conformance): move conformance snapshots into separate directory (#5924) 2024-09-20 12:30:39 +00:00
Boshen 63a830e08c chore(dprint): format toml files (#5599)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-08 14:26:16 +08:00
Boshen 6800e694e3 feat(oxc): add Compiler and CompilerInterface (#4954)
This PR adds a full compiler pipeline to the `oxc` crate, to stop us
from implementing the same pipeline over and over again.

relates #4455
2024-08-19 10:20:05 +08:00
Boshen 873d502993 refactor(coverage): use the oxc crate 2024-08-17 22:40:08 +08:00
Boshen c220730779 feat(coverage): check symbols and scopes after transformation (#4917)
closes https://github.com/oxc-project/oxc/issues/4790

@overlookmotel enjoy ... take a look at the snapshots and probably nothing else.

The snapshots are minimal right now, but it's already showing symbols from import specifiers are not being removed. We can iterate on the snapshot representation to aid debugging later.

I'll extend this to `transformer_conformance` and `oxc-monitor` in an up coming PR.
2024-08-16 07:05:11 +00:00
Boshen 83bd40db4e chore: turn off doctest for all [[bin]] 2024-07-14 16:55:19 +08:00
Boshen 87c3282deb chore(transformer-dts): change crate to oxc_isolated_declarations (#3713) 2024-06-17 11:14:13 +00:00
Boshen eff9cff048 feat(coverage): add dts transform coverage test (#3675) 2024-06-14 14:29:27 +00:00
Boshen 1e84644220 chore: update toml format 2024-05-21 22:15:47 +08:00
Boshen 67225a8091 refactor(coverage): replace yaml parsing with saphyr (#3144)
closes #3128

Profiling `cargo run -p oxc_coverage -- parser` no longer shows a
bottleneck in yaml parsing
2024-04-30 22:49:39 +08:00
Boshen d57526103c feat(coverage): add transformer to prevent crashes (#2970) 2024-04-14 18:52:51 +08:00
underfin b199cb89a2 feat: add oxc sourcemap crate (#2825)
The sourcemap implement port from
[rust-sourcemap](https://github.com/getsentry/rust-sourcemap), but has
some different with it.

- Encode sourcemap at parallel, including quote `sourceContent` and
encode token to `vlq` mappings.
- Avoid `Sourcemap` some methods overhead, like `SourceMap::tokens()`
caused extra overhead at common cases. Here using `SourceViewToken` to
instead of it.
2024-03-28 19:36:38 +08:00
Boshen 95fc28168c chore: apply cargo autoinherit (#2826)
See https://github.com/mainmatter/cargo-autoinherit
2024-03-26 23:57:50 +08:00
Boshen e32a3b3783 ci: use cargo-shear (#2810) 2024-03-26 00:43:10 +08:00
renovate[bot] 3d761f17c2 chore(deps): lock file maintenance rust crates (#2804) 2024-03-25 17:24:30 +08:00
renovate[bot] 1e9c0bc484 chore(deps): update rust crates (#2747) 2024-03-17 16:40:42 +00:00
Boshen 697b6b70c0 feat: merge features serde and wasm to serialize (#2716)
This PR merges the previous confusing features `serde` and `wasm` into a
single `serialize` feature.

We'll eventually do serialize + type information for both wasm and napi
targets.

`oxc_macros` is removed from `oxc_ast`'s dependency because it requires
`syn` and friends, which goes against our policy ["Third-party
dependencies should be
minimal."](https://oxc-project.github.io/docs/contribute/rules.html#development-policy)
2024-03-14 17:13:12 +08:00
Boshen 265b2fb640 feat: miette v7 (#2465) 2024-03-08 15:50:00 +08:00
renovate[bot] 29b213eac7 chore(deps): update rust crates (#2503) 2024-02-26 10:38:11 +08:00
Boshen 1cbd7539fb feat(coverage): add prettier idempotency test (#2402)
closes #1329
2024-02-12 15:30:16 +08:00
Boshen 70a0076eed refactor: remove global allocator from non-user facing apps (#2401)
The runtime performance gains does not out weight the compilation speed from
building the custom allocators, which takes about a minute to build on
slower machines.
2024-02-12 14:09:05 +08:00
renovate[bot] d7a9bcf191 chore(deps): update rust crates (#2199) 2024-01-30 15:30:22 +08:00
dependabot[bot] 21909fa962 chore(deps): bump the dependencies group with 3 updates (#2033) 2024-01-15 15:31:32 +08:00