Commit Graph

798 Commits

Author SHA1 Message Date
overlookmotel 4ee94a3308 feat(napi/parser): export visitor keys (#13927)
Add visitor keys export to `oxc-parser` NPM package. This is useful in itself, but also the first step towards an ESTree walker.

Visitor keys are based on `@typescript-eslint/visitor-keys`.

It'd be ideal to generate visitor keys direct from Oxc's own types, but that's proving difficult due to all the custom serializers we use to translate to ESTree. So using the shortcut of borrowing from TS-ESLint for now.

Oxc's AST is slightly different from TS-ESTree (notably Oxc's AST adds `ParenthesizedExpression`). But apart from those few differences, TS-ESLint's AST and Oxc's are identical, and I made a PR to TS-ESLint earlier this year (https://github.com/typescript-eslint/typescript-eslint/pull/11279) to ensure visitor key order is correct, and matches Oxc.

To avoid adding a runtime dependency on `@typescript-eslint/visitor-keys`, extract the data from TS-ESLint in `oxc_ast_tools`, amend for Oxc/TS-ESTree differences, and re-output it as a simple object literal.

This approach will be faster at runtime, as the object's shape is consistent, and also avoids a dependency.
2025-09-22 11:08:46 +00:00
overlookmotel 80c2d03ab4 ci(release): fix release workflow for NAPI packages (#13979)
Fix (hopefully) the release workflow for NAPI packages, after it was broken by #13899.
2025-09-21 14:57:24 +00:00
overlookmotel 48062d06df refactor(napi/parser): itemize files in package.json (#13978)
#13899 made the `files` array in `package.json` for `napi/parser` package a short list of directories. Revert to an itemized list of all files to be included in NPM package.

This is for compatibility with the release workflow which checks the list of files in `package.json` against file system. It fails when `files` list contains directories.
2025-09-21 14:52:09 +00:00
overlookmotel 01859848b1 fix(napi/parser): raw transfer preserveParens option apply to TSParenthesizedType (#13964)
Partial fix for #13851.

Raw transfer `preserveParens` option remove `TSParenthesizedType`s from AST, same as #13855 removed `ParenthesizedExpression`s.

This is not used in `oxc-parser`, but the raw transfer `preserveParens` option is required in `oxlint` JS plugins, to align with TS-ESLint, which has no `TSParenthesizedType`s in its AST.
2025-09-21 10:13:02 +00:00
Boshen fb347da614 release(crates): v0.91.0 (#13961) 2025-09-21 13:23:09 +08:00
overlookmotel 7a50ad99be docs(napi/parser, napi/transform): correct README examples (#13934)
Docs were out of date. `oxc-parser` and `oxc-transform` packages are now ESM-only, so the code examples would no longer run. Correct them.
2025-09-19 19:58:04 +00:00
overlookmotel bd2fa90b8b fix(napi/parser): move browser.js file (#13918)
Fix something I missed in #13899. `browser.js` is auto-generated by NAPI-RS, so needs to be in `src-js` dir with the rest.
2025-09-19 09:19:55 +00:00
overlookmotel 329b7e7150 refactor(napi/parser): move scripts to scripts directory (#13900)
Continuation of #13899. Move scripts from root of `napi/parser` package into a `scripts` directory.
2025-09-19 08:46:43 +00:00
overlookmotel ac3e9e966a refactor(napi/parser): move JS code into src-js directory (#13899)
Pure refactor. Root of `napi/parser` was getting really crowded with tons of files, and I'm about to add a load more for the ESTree walker.

Move JS source files into a `src-js` directory, like in `apps/oxlint`, so that the root of the package is just config files and scripts.
2025-09-19 08:46:42 +00:00
overlookmotel 5ff91bc247 fix(napi/parser): fix example (#13887)
Import path in `napi/parser` example was wrong. The entry point is now `index.mjs`.
2025-09-18 16:27:43 +01:00
overlookmotel 2cef8ecbdd refactor(napi/parser): remove outdated comment (#13886)
Pure refactor. `wrap.cjs` no longer exists, so this comment is outdated. Remove it.
2025-09-18 16:27:43 +01:00
overlookmotel 21bbf959b8 fix(napi): rebuild bindings file for NAPI packages (#13889)
#13888 broke CI because it didn't run `pnpm build` to update version number in NAPI bindings files.

I don't think the published packages are broken, because it only matters if `NAPI_RS_ENFORCE_VERSION_CHECK` env is set.
2025-09-18 14:37:42 +00:00
Boshen d116504831 release(crates): v0.90.0 (#13888) 2025-09-18 22:07:37 +08:00
Copilot b52389a569 feat(node): Bump engines field to require Node.js 20.19.0+ for ESM support (#13879)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-09-18 20:10:11 +08:00
overlookmotel 24a21b3185 feat(napi/parser): preserveParens option for raw transfer (#13855)
Partial fix for #13851.

Add a `preserveParens` argument to raw transfer `deserialize` functions. This is not useful in `oxc-parser`, but these generated files will be duplicated in `oxlint`, where this option is required to remove `ParenthesizedExpression`s from AST, to align with ESLint and TS-ESLint.
2025-09-17 11:38:40 +00:00
overlookmotel 42b100095e refactor(napi/parser): export functions directly (#13854)
Pure refactor. Export functions directly with `export function` instead of an additional `export { ... }` statement. This makes it easier to see which functions are exported and which are not.
2025-09-17 11:16:49 +00:00
Boshen 9796ec12d7 fix(napi): fix binding files 2025-09-15 14:55:01 +08:00
Boshen de40f0bee0 release(crates): v0.89.0 (#13774) 2025-09-15 14:33:03 +08:00
renovate[bot] b4e9d2c379 chore(deps): lock file maintenance npm packages (#13758)
Co-authored-by: Boshen <boshenc@gmail.com>
2025-09-15 13:15:05 +08:00
Ari Perkkiö 341791e4e3 fix(parser): invalid main entrypoint in package.json (#13767)
In https://github.com/oxc-project/oxc/pull/13432 the filename was
changed but `main` remained as is. I'm now seeing following error in
Vitest:

```
⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯
Error: Failed to resolve entry for package "oxc-parser". The package may have incorrect main/module/exports specified in its package.json.
1  |  import { parse as BabelParser } from "@babel/parser";
2  |  import { parse as AcornParser } from "acorn";
3  |  import { parseSync as OxcParser } from "oxc-parser";
   |                                          ^
4  |  import { parseAst as ViteParser } from "vite";
5  |  import { expectTypeOf, test } from "vitest";
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
```


https://github.com/AriPerkkio/ast-v8-to-istanbul/actions/runs/17722503037/job/50357275013?pr=86

See errors from https://publint.dev/oxc-parser@0.88.0.

Signed-off-by: Ari Perkkiö <ari.perkkio@gmail.com>
2025-09-15 13:14:35 +08:00
Boshen 369287abac release(crates): v0.88.0 (#13765)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-09-15 11:01:32 +08:00
overlookmotel ab5139440b fix(raw_transfer): disable layout assertions on some 32-bit platforms (#13716)
Fixes #13694.

Some 32-bit platforms give `u64` and `f64` alignment of 8, and others alignment of 4. WASM32 uses alignment 8, and layout calculator assumes that.

Skip layout assertions for platforms where alignment is 4, because we know some layouts are wrong for those platforms, and it causes compilation failure in debug builds. But retain the assertions for other 32-bit platforms (notably WASM), to make sure they remain correct. This will make it easier to extend raw transfer support to WASM later on.
2025-09-12 06:23:59 +00:00
overlookmotel babbaca73f refactor(all): remove pub from modules with no exports (#13618)
Pure refactor. All these generated modules have no exports, so importing them with `pub mod` is misleading - there is nothing to make public. Import them with plain `mod` instead.

```diff
mod generated {
- pub mod assert_layouts;
+ mod assert_layouts;
}
```
2025-09-10 02:39:20 +00:00
Boshen 4577b71ec8 feat(napi/parser)!: change oxc-parser to ESM (#13432)
closes #13329
2025-09-08 10:53:05 +00:00
oxc-bot 7128fb57dd release(crates): v0.87.0 (#13587)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-09-08 11:35:41 +08:00
renovate[bot] 700c3b1d88 chore(deps): lock file maintenance npm packages (#13582)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Boshen <boshenc@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-08 11:01:53 +08:00
renovate[bot] 12a5e36bfc chore(deps): update dependency tinypool to v2 (#13482)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [tinypool](https://redirect.github.com/tinylibs/tinypool) | [`^1.1.0`
-> `^2.0.0`](https://renovatebot.com/diffs/npm/tinypool/1.1.1/2.0.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/tinypool/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/tinypool/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/tinypool/1.1.1/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/tinypool/1.1.1/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>tinylibs/tinypool (tinypool)</summary>

###
[`v2.0.0`](https://redirect.github.com/tinylibs/tinypool/releases/tag/v2.0.0)

[Compare
Source](https://redirect.github.com/tinylibs/tinypool/compare/v1.1.1...v2.0.0)

#### What's Changed

- fix!: drop Node 18 support by
[@&#8203;AriPerkkio](https://redirect.github.com/AriPerkkio) in
[#&#8203;118](https://redirect.github.com/tinylibs/tinypool/pull/118)
- perf: use `availableParallelism` instead of `exec` by
[@&#8203;sheremet-va](https://redirect.github.com/sheremet-va) in
[#&#8203;123](https://redirect.github.com/tinylibs/tinypool/pull/123)

**Full Changelog**:
<https://github.com/tinylibs/tinypool/compare/v1.1.1...v2.0.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 9am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS45MS4xIiwidXBkYXRlZEluVmVyIjoiNDEuOTEuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-31 19:03:19 +00:00
oxc-bot 7652c8d6ab release(crates): v0.86.0 (#13464)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-08-31 18:46:10 +08:00
oxc-bot 42ebd43ba0 release(crates): v0.85.0 (#13413)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-08-30 15:44:00 +08:00
oxc-bot d6a8aa1ce0 release(crates): v0.84.0 (#13412)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-08-30 13:15:55 +08:00
oxc-bot 732c57e55e release(crates): v0.83.0 (#13387)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-08-29 14:49:51 +08:00
oxc-bot 8b1e022f7f release(crates): v0.82.3 (#13230) 2025-08-20 23:19:06 +08:00
overlookmotel 5baa4f1467 refactor(napi/parser): fix lint errors (#13185)
Same as #13184.

#13173 enabled Oxlint for all the repo, but we currently skip `napi` directory.

Fix all errors that Oxlint flags in `napi/parser`.

We currently can't turn on Oxlint for the directory, because `oxlint-disable` comments don't work for type-aware rules, but we should be able to once that's fixed.
2025-08-18 22:14:15 +00:00
oxc-bot 4d0a05e1e7 release(crates): v0.82.2 (#13158) 2025-08-17 23:31:38 +08:00
overlookmotel ecc9c60440 perf(napi/parser): raw transfer: reduce maths complexity (#13145)
Tiny perf optimization.

Reduce complexity of maths by doing as much calculation as possible using consts.

Shaves off 1 operation! https://godbolt.org/z/5h4hzznxs

This change does not alter the result. `data_offset + RAW_METADATA_SIZE` couldn't overflow because `data_offset` was derived from a `u32`, and this code (raw transfer) is only run on 64-bit systems, so there's plenty of headroom in `usize`. But it does make it easier to support 32-bit in future.
2025-08-16 17:16:02 +00:00
overlookmotel f6ac2e6826 refactor(allocator, napi/parser): use usize::is_multiple_of (#13142)
Pure refactor. When this code was written, `usize::is_multiple_of` was not available in our MSRV. Now it is, so use it instead of writing the same function ourselves.
2025-08-16 14:24:02 +00:00
Kevin Deng d5431999d0 chore(napi): fix publint issues (#13107)
See https://publint.dev/oxc-parser
2025-08-15 22:25:18 +08:00
oxc-bot 92a3550c40 release(crates): v0.82.1 (#13049) 2025-08-13 12:24:37 +08:00
oxc-bot c58a699e19 release(crates): v0.82.0 (#13014) 2025-08-12 13:53:10 +08:00
renovate[bot] 9e69e1abef chore(deps): lock file maintenance npm packages (#12973) 2025-08-11 14:17:42 +08:00
overlookmotel bf9ae3b087 refactor(ast/estree): remove custom serializer for TSImportTypeQualifier (#12961)
Follow-on after #12801.

Remove the custom serializer for `TSImportTypeQualifier`. All we need is to rename `TSImportTypeQualifiedName` to `TSQualifiedName`, so we can use `#[estree(rename = "TSQualifiedName")]`, and let the codegen do the rest.
2025-08-10 11:21:19 +00:00
oxc-bot c245d9bf78 release(crates): v0.81.0 (#12850) 2025-08-06 23:05:58 +08:00
overlookmotel 2cc1001301 refactor(ast)!: remove ExportDefaultDeclaration exported field (#12808)
We currently store the `default` keyword for `ExportDefaultDeclaration` as a `ModuleExportName`. This is overkill because the name is always, by definition, `default`.

The only place the `Span` of `default` keyword is used is in `ModuleRecordBuilder`. So essentially storing the span in AST is using the AST as temporary storage - it's only put there so that `ModuleRecordBuilder` can pull it out again.

After #12807, we can just pass the span direct to `ModuleRecordBuilder`, and so remove the need for it to be in the AST at all.

So we can remove the whole field.

This reduces size of `ExportDefaultDeclaration` from 80 bytes to 24. That has very limited impact, because each file can only have 1 `export default` statement. But still... less is more!

It also removes erroneous code in both isolated declarations and transformer, which both just gave the keyword an empty span. I think the fact that everywhere that does use this field uses it wrongly is good justification for its removal!

(alternative to #12803)
2025-08-05 08:14:50 +00:00
camc314 47e2c593a9 fix(estree): fix serialization of TSImportTypeQualifier (#12801) 2025-08-05 05:55:42 +00:00
camc314 50b91ac7fa feat(ast)!: remove IdentifierReference from qualifier field of TSImportType (#12799)
closes #12042, #12797
2025-08-05 05:55:42 +00:00
oxc-bot 9671def11f release(crates): v0.80.0 (#12777) 2025-08-03 16:38:23 +08:00
overlookmotel 0ec214b4aa test(napi): compile tests in debug mode (#12750)
Compile NAPI tests in debug mode (not release mode), to speed up build in CI.

Only exception is `napi/parser` which is compiled with `--profile coverage`. The tests for this package are quite slow, so they'd take too long if package was compiled with no optimizations. `coverage` profile is closer to `--release`, but enables debug assertions, and has somewhat faster compilation (`-O 2` not `-O 3` etc).

In CI:

* Build time reduced by 1m30s.
* Test run time increased by 30s.
* Total reduction in CI time: 1 minute.

NAPI tests are still the slowest task in CI by a long margin. Trimming a minute off the time is something, but this task is still too slow.
2025-08-02 12:18:41 +00:00
overlookmotel 2f255a06e4 test(napi/parser): ensure target dir exists (#12751)
In tests for `napi/parser`, don't assume `target` dir exists. It generally should, because you'll have built the `.node` binary. But it `cargo clean` will remove it, and it can also not exist on CI if running build and test in separate jobs.
2025-08-02 11:04:47 +00:00
overlookmotel 02504b927b test(napi/parser): disable raw transfer tests by default (#12742)
See: https://github.com/oxc-project/oxc/issues/12435#issuecomment-3144750987

Disable raw transfer tests by default. To run them locally, use `RUN_RAW_TESTS` env:

```sh
RUN_RAW_TESTS=true pnpm test
```

Raw transfer tests are still enabled in CI.
2025-08-02 03:04:48 +00:00
overlookmotel cd93174798 refactor(ast)!: introduce WithClauseKeyword (#12741)
`WithClause` keyword can only be one of 2 words - `with` or `assert`.

We don't need `Span` for this symbol, so using `IdentiferName` (24 bytes) is overkill. Just use an enum `WithClauseKeyword` (1 byte).

This also has the benefit of constraining the keyword to valid values - prevents creating an invalid AST which would be printed as e.g. `import foo from "source" TROUSERS {};`.
2025-08-02 02:56:03 +00:00