Commit Graph

811 Commits

Author SHA1 Message Date
overlookmotel 8c09592d2c test(napi/parser): align fixture version with other tasks (#14146)
#13465 aligned the version of `antd.js` used in different Rust tasks to v4.16.1. But it missed a couple of places in `napi/parser` tests/benchmarks. Align these to same version too.

Misalignment was problematic as the tasks using these fixtures all download the file to same location (`target` dir) and don't re-download if the file is already present. This lead to unpredictable results depending on which task you ran first, and so which version was downloaded.
2025-09-26 09:41:48 +00:00
overlookmotel c0c0c1755a refactor(napi/parser): remove unnecessary #[estree(field_order)] attr (#14144)
`span` is now automatically moved to be last field, so no need to specify field order explicitly here.
2025-09-26 10:34:51 +01:00
Boshen 1b3f437468 release(crates): v0.92.0 (#14067) 2025-09-24 12:18:07 +08:00
overlookmotel cc0019fb0a refactor(napi): move scripts into scripts directory (#14048)
Move all build scripts in `napi` packages into a `scripts` dir. These packages don't have root directories with tons of files like `napi/parser` and `apps/oxlint` do, but IMO it's preferable to have a consistent directory structure in all NAPI packages.

Also, rename these scripts from `.mjs` to `.js`, since these packages are ESM.
2025-09-23 14:47:41 +00:00
overlookmotel bb040bc2d5 refactor(parser, linter): replace .mjs files with .js (#14045)
Now that `apps/oxlint` and `napi/parser` are both ESM packages (#13723 and #14042), we can use `.js` file extensions for all ESM files, rather than the mix of `.js` and `.mjs` file we had previously.

It's less confusing having to remember what's `.js` and what's `.mjs`, and avoids ugly workarounds like #14038 (`.d.mts`??).
2025-09-23 14:47:40 +00:00
overlookmotel b1da5d5ce6 feat(napi/parser)!: change oxc-parser to ESM (#14042)
Completion of the work begun in #13432. Make `oxc-parser` package fully ESM.

Aside from adding `"type": "module"` to `package.json`, only other change required is renaming `webcontainer-fallback.js` -> `webcontainer-fallback.cjs`. All other files already have the extension matching their ESM/CommonJS content.
2025-09-23 14:28:31 +00:00
overlookmotel 909a086f6e docs(parser): simplify example (#14044)
Pure refactor. Remove unnecessary `main` function, to clarify the example.
2025-09-23 13:15:33 +00:00
overlookmotel 55cd2f3058 test(parser): remove unused import (#14043) 2025-09-23 13:15:33 +00:00
Daniel Roe 1f4be382a8 fix(napi/parser): generate .d.mts extension for types (#14038)
the latest version of `oxc-parser` (on npm) does not have resolvable
types because the entry is `.mjs` and the types are `.d.ts` (these need
to match - `.d.mts`). you can see this in the failing CI for [this
renovate
PR](https://github.com/nuxt/nuxt/actions/runs/17940186619/job/51014702361?pr=33290)
but I'm happy to provide a more minimal reproduction if it helps

I also spotted that `napi/parser/test/visit.test.ts` was importing
`visitorKeys` which was not exported from the corresponding declaration,
so took the liberty to add that export as well.

let me know if this needs any changes 🙏 

I hope it helps

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2025-09-23 11:53:20 +01:00
overlookmotel e0be08b311 refactor(napi/parser): freeze visitorKeys export (#14012)
Freeze `visitorKeys` which `oxc-parser` exports. This follows TS-ESLint, and will be useful for `oxlint`.
2025-09-22 20:50:04 +00:00
Boshen cb55daa1c5 release(crates): v0.91.0 (#14000) 2025-09-22 19:24:10 +08:00
overlookmotel d49fb3b54d feat(napi/parser): add deserializeProgramOnly deserializer function (#13940)
Pure refactor. Add a function `deserializeProgramOnly` to generated deserializer code. This function is not used in `oxc-parser`, but is needed to be able to reuse the same code in Oxlint.
2025-09-22 11:08:46 +00:00
overlookmotel 56a385fe94 feat(napi/parser): add AST walker (#13930)
Add an AST visitor to `oxc-parser`.

```js
import { parseSync, Visitor } from 'oxc-parser';

const { program } = parseSync('test.js', 'let x = { y: z };');

const idents = [];
const visitor = new Visitor({
  Identifier(node) {
    idents.push(node.name);
  }
});

visitor.visit(program);

// Logs [ 'x', 'y', 'z' ]
console.log(idents);
```

Primarily we need a visitor for Oxlint plugins, but it's easier to develop and test in `oxc-parser`, so I thought I'd add it there first. Oxlint build process will copy the generated files for tree-walking from `napi/parser` dir, as it does with other files.

Notes:

* The `walk.mjs` file is large, so it's lazy-loaded only when user first constructs a `Visitor`. Adding `Visitor` to the package will not affect start-up time where user only uses `parseSync` etc.
* TS type definition for `Visitor` and the visitor object it takes are provided.
* Visitor supports enter and exit visitors e.g. `Program` and `Program:exit`.
* `src-js/visit/visitor.mjs` is copied from `apps/oxlint` with only minor modifications, and conversion from TS to JS. It'd be better if we only had this impl in one place, but that would require converting `oxc-parser` to TS and building with TSDown, like `oxlint` is. Leaving that for later - #13935.
2025-09-22 11:08:46 +00:00
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