Commit Graph

1234 Commits

Author SHA1 Message Date
overlookmotel 7d462fa079 fix(napi/oxlint): prevent compilation failure on WASM32 (#13711)
It is a compilation error to load `generated::raw_transfer_constants` on 32-bit platforms, and JS plugins are only supported on little-endian 64-bit platforms.

Feature gate all JS plugin-related code so it does not get loaded on unsupported platforms. This should allow `napi/oxlint` to be built as WASM32.
2025-09-12 05:27:56 +00:00
overlookmotel 079c2f283e refactor(napi/oxlint): move external linter construction into own module (#13710)
Pure refactor. Move `wrap_*` functions into separate `external_linter.rs` module, and add a `create_external_linter` function which wraps both JS callbacks.

This is necessary so we can feature gate loading the module (next PR #13711).
2025-09-12 05:16:24 +00:00
overlookmotel a0022c17d0 refactor(linter/plugins): improve error messages for JS plugins (#13699)
Amend error messages related to JS plugins. "external" is the term we use in the codebase, but it probably wouldn't make much sense to end users. Use the term "JS plugin" instead.
2025-09-12 04:19:41 +00:00
overlookmotel 9126c93ef5 test(napi/oxlint): add tests for without JS plugins enabled (#13698)
Add a couple of tests to make sure `napi/oxlint` operates correctly without `--experimental-js-plugins` CLI option.
2025-09-12 04:19:41 +00:00
overlookmotel 3f84157d55 build(napi/oxlint): flatten dist directory structure (#13697)
Pure refactor. Flatten directory structure of `dist` dir a little, by removing `parser` dir.
2025-09-12 04:19:41 +00:00
overlookmotel 04b98092d5 build(napi/oxlint): do not extern constants.mjs (#13696)
Surprisingly, TSDown inlines the constants from `constants.mjs` into the bundled code, regardless of whether the file is listed as `external` in TSDown config. So remove it from `external` list and don't copy the file into `dist`.
2025-09-12 04:19:40 +00:00
overlookmotel d13b5b2941 build(napi/oxlint): simplify build script (#13695)
Pure refactor. Simplify the build script for `napi/oxlint`. Does not alter the files which end up in `dist` directory.
2025-09-12 04:10:31 +00:00
overlookmotel 1fd993f54f refactor(napi/oxlint): rename napi/oxlint2 to napi/oxlint (#13682)
Rename `napi/oxlint2` to `napi/oxlint`. This is in preparation for migrating code from `napi/oxlint` into `apps/oxlint`. This PR is incidental, but renaming everything in this PR will reduce diff when moving code over to `apps/oxlint`.
2025-09-12 03:44:25 +00:00
Boshen 08c05df60c perf(semantic): make CFG construction a compile-time feature (#13678)
part of #13646

## Summary

This PR converts the Control Flow Graph (CFG) functionality in `oxc_semantic` from runtime checks to a compile-time cargo feature, eliminating runtime overhead when CFG is not needed.

## Changes

- Added `cfg` cargo feature to `oxc_semantic/Cargo.toml` with `oxc_cfg` as optional dependency
- Feature-gated all CFG-related code using `#[cfg(feature = "cfg")]`
- Updated `oxc_linter` to enable the `cfg` feature (since it requires CFG)
- Made the `control_flow!` macro work correctly with and without the feature

## Benefits

- **Performance**: Eliminates runtime `Option<CFG>` checks when feature is disabled
- **Binary size**: Smaller binaries for crates that don't need CFG
- **Cleaner API**: CFG methods only available when feature is enabled

## Test Plan

- [x] All existing tests pass with `cargo test -p oxc_semantic --features cfg`
- [x] `oxc_linter` builds and works correctly (it enables the feature)
- [x] Feature is backward compatible - existing code continues to work

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-09-11 12:44:19 +00:00
overlookmotel 7775c21a61 refactor(linter/plugins): remove oxlint2 Cargo feature (#13648)
Remove `oxlint2` Cargo feature from `oxlint` and `oxc_linter` crates.

Now that enabling `fixed_size` Cargo feature of `oxc_allocator` doesn't change behavior, we don't need the feature gate. The incompatibility of `tokio` with WASM has been resolved by #13647.
2025-09-11 06:18:53 +00:00
overlookmotel 2d5320337e refactor(linter/plugins): move tokio usage from oxc_linter to napi/oxlint2 (#13647)
`tokio` is required to run `load_plugin` JS callback, to load a JS plugin.

Move this code into `napi/oxlint2`, so can remove the `tokio` dependency from `oxc_linter` crate.
2025-09-11 05:23:08 +00:00
overlookmotel 6cd6be253d refactor(linter): add --experimental-js-plugins CLI arg (#13658)
Add `--experimental-js-plugins` CLI option to `oxlint`.

At present this option is hidden in the CLI's `--help` output.

If this option is not present, `ExternalLinter` is dropped, which disables JS plugins.

Therefore, JS plugins are only enabled, and code related to them (e.g. fixed size allocators) runs only if both:

1. `oxlint` is run via `napi/oxlint2`.
2. `--experimental-js-plugins` CLI option is present.

This prepares the way for switching `oxlint` over to `napi/oxlint2`.
2025-09-11 05:17:25 +00:00
overlookmotel daae07d012 feat(napi/oxlint2): lazy-load code for handling JS plugins (#13663)
`napi/oxlint2` will soon become the default version of `oxlint`. It will support JS plugins, but only behind an `--experimental-js-plugins` option. Most users will not be using JS plugins.

Therefore, don't load the code for loading/running JS plugins upfront. Instead, lazy-load the code when Rust first calls into JS asking it to load a JS plugin. This means the addition of JS plugin support should not affect perf for users who aren't using JS plugins.
2025-09-11 02:50:33 +00:00
overlookmotel f182ab2f18 refactor(napi/oxlint): split into multiple files (#13662)
Pure refactor. In `napi/oxlint2`, split up code into more files, and move all code related to JS plugins (almost all of it) into `plugins` directory.

None of the code is altered, it's just moved around. Only code change is adding a few more comments and 1 type annotation.

This prepares the way for:

1. Lazy-loading the JS plugin code (next PR).
2. Adding a 2nd version of visitor which doesn't use lazy deserialization.
2025-09-11 01:41:46 +00:00
overlookmotel f8b0964c1c build(napi/oxlint): do not fully minify JS code (#13661)
Alter TSDown settings for `napi/oxlint2`.

We intended the code to be minified, but not to have symbols mangled, or whitespace removed, so it remains somewhat readable. It seems that TSDown may have changed how it handles these options, as `minify: { compress: true }` now turns on mangling and whitespace removal.

Alter the TSDown options to get the intended output.
2025-09-10 17:49:38 +00:00
overlookmotel 51f26407f7 refactor(linter/plugins): rename var (#13640)
Pure refactor. Rename var so name better represents what it is.
2025-09-10 04:46:50 +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
Copilot ea259af607 feat(playground): add experimental decorators options (#13602)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
2025-09-09 10:54:23 +08:00
Boshen 4577b71ec8 feat(napi/parser)!: change oxc-parser to ESM (#13432)
closes #13329
2025-09-08 10:53:05 +00:00
Copilot 89084d73c1 fix(linter/custom-plugins): enforce exact matching for disable directives (#13538)
Implement support for disable directives (like `// oxlint-disable-next-line`) for custom plugin rules.

The full name of the rule (including plugin name) is required in the disable comment e.g.:

```js
// oxlint-disable-next-line my-plugin/my-rule
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2025-09-08 12:30:29 +07: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
Boshen ddaebf7571 feat(napi/playground): add more options (#13523) 2025-09-02 17:52:19 +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
Boshen 34d0a014f6 feat(napi/minify,transform)!: change module type to ESM (#13349)
part of #13329
2025-08-28 12:47:24 +00:00
overlookmotel 8a34ad2028 style(napi/oxlint): reformat test cases (#13345)
Pure code style change. Compact the tests code for `napi/oxlint2`.
2025-08-28 09:32:48 +00:00
overlookmotel d1c9db5368 feat(linter): convert spans to UTF-16 in JS plugins (#13344)
The AST on JS side in linter JS plugins previously had `start` and `end` as UTF-8 offsets.

Convert the AST to UTF-16 offsets prior to transferring it to JS, and convert offsets in any errors/warnings returned from JS side back to UTF-8 before creating `OxcDiagnostic`s from them.

The tricky part is that it's not possible to mutate the AST (convert offsets to UTF-16) while `Semantic` is alive, because you can't obtain a `&mut Program` due to aliasing rules. Work around this with some pointer juggling and by dropping `Semantic` before creating a `&mut Program`.

This is a bit sketchy, but is not (I believe) UB. Hopefully we can remove the need for this workaround later on by performing offset conversion during serialization / raw transfer deserialization, and so avoid the need to mutate the AST.
2025-08-28 09:32:48 +00:00
overlookmotel 53de36efcc refactor(linter): ContextSubHost hold owned Semantic (#13338)
`ContextSubHost` does not share `Semantic` with any other structure, so `Rc<Semantic>` is unnecessary overhead. Make it contain owned `Semantic` instead.
2025-08-27 22:34:26 +00:00
Sysix e871dab146 refactor(linter): run linter with ContextSubHost (#12769)
Here we are not aligning every diagnostic to the source text offset. Later we could cross-reference with an extra method `push_diagnostic_without_adjustment` or something similar.
2025-08-27 02:02:30 +00:00
Boshen cc32fcb03d chore(napi/playground): skip building for tests (#13304)
closes #12435
2025-08-26 03:42:56 +00:00
sapphi-red 593f54ccb6 feat(minifier): add --max-iterations for debugging (#13291)
Added `--max-iterations` to make it easier to debug what has changed in each iteration.
2025-08-25 14:47:06 +00:00
sapphi-red a0e0a91688 feat(oxc_minify_napi): expose CodeGenOptions (#13288)
Follow up to #13239
2025-08-25 07:56:31 +00:00
oxc-bot 8b1e022f7f release(crates): v0.82.3 (#13230) 2025-08-20 23:19:06 +08:00
IWANABETHATGUY d86f732836 chore(oxc_minify_napi): expose more options struct (#13239)
Allow the downstream user to construct a napi options on their own, a
use case in rolldown
https://github.com/rolldown/rolldown/pull/5804/files#diff-56038ed67657ce910f150123cdc2d8ab42bd9bcd9745192c3127f2d837c78865R248,
we need to convert options back to `oxc_minify_napi`, since
`oxc::minify::options` did not implement `toNapi` trait.
2025-08-20 23:18:20 +08:00
Dunqing 76a9865af0 fix(transformer/legacy-decorator): metadata should be inserted after all params decorators (#13215)
* Fixes https://github.com/oxc-project/oxc/issues/13210
2025-08-19 16:08:53 +00:00
overlookmotel c26d303557 refactor(napi/oxlint2): fix lint errors (#13184)
#13173 enabled Oxlint for all the repo, but we currently skip `napi` directory.

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

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-19 15:07:55 +00: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
Boshen f10ac33979 fix(codegen): remove end sourcemaps for }, ], ) (#13180)
closes #13174

This should reduce sourcemap memory usage by a huge amount.

These tokens were added in esbuild for code coverage: https://github.com/evanw/esbuild/commit/c4d45e6b5766b1a1b56bf24b7dadb240de91332b

But esbuild has an optimization to not generate these tokens when `}` is not on the same line

```
if class.CloseBraceLoc.Start > class.BodyLoc.Start {
    p.addSourceMapping(class.CloseBraceLoc)
}
```

We should revisit these tokens later in the future.
2025-08-18 11:45:14 +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
overlookmotel c8b97decec refactor(napi/parser): move creating JS buffer into separate function (#13133)
Refactor only. Move block of code for creating a JS buffer out into its own function. This code is going to get more complicated to accommodate JS plugins on multiple threads.
2025-08-16 11:55:49 +00:00
Sysix aecacae8ce feat(linter): support ignorePatterns for nested configs (#12210)
Now every `ignorePatterns` configuration in nested configuration are respected.
Before, only `ignorePatterns`, which are located in the base-configuration of the project, would be respected.

Closes #11067
Closes #12857
Closes #11969
2025-08-16 10:00:41 +00:00
overlookmotel 83d25ce31f refactor(linter): fix typo in comment (#13125) 2025-08-15 16:24:30 +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
Boshen 522356201b refactor(codegen): adjust some source mappings (#13084)
closes #12395
2025-08-14 09:54:29 +00:00