Commit Graph

229 Commits

Author SHA1 Message Date
oxc-bot 38d1302267 release(crates): v0.58.0 (#9740) 2025-03-13 16:58:56 +08:00
oxc-bot 8d18dc4207 release(crates): v0.57.0 (#9668)
## [0.57.0] - 2025-03-11

- 510446a parser: [**BREAKING**] Align JSXNamespacedName with ESTree
(#9648) (Arnaud Barré)

- b0d979d semantic: [**BREAKING**] Make `Scoping::references` private
(#9629) (Boshen)

- 3c6f140 semantic: [**BREAKING**] Make `Scoping` methods consistent
(#9628) (Boshen)

- ef6e0cc semantic: [**BREAKING**] Combine `SymbolTable` and `ScopeTree`
into `Scoping` (#9615) (Boshen)

- 7331656 semantic: [**BREAKING**] Rename `SymbolTable` and `ScopeTree`
methods (#9613) (Boshen)

- 23738bf semantic: [**BREAKING**] Introduce `Scoping` (#9611) (Boshen)

### Features

- b6deff8 ecmascript: Support integer index access for array and string
in `may_have_side_effects` (#9603) (sapphi-red)
- 047fb01 minifier: Place `void 0` on right hand side if possible
(#9606) (sapphi-red)
- 36f8703 minifier: Compress `[] + string` to `string` (#9602)
(sapphi-red)
- 554c4ce minifier: Compress constant integer index access (#9604)
(sapphi-red)
- e3c2015 minifier: Allow compressing computed __proto__ more precisely
(#9595) (sapphi-red)
- 6a57198 minifier: Allow compressing computed constructor/prototype
keys precisely (#9594) (sapphi-red)
- 638007b parser: Apply `preserveParens` to `TSParenthesizedType`
(#9653) (Boshen)

### Bug Fixes

- eae1a41 ast: Align `TSImportType` field names with ts-eslint (#9664)
(Boshen)
- 96eef8b ecmascript: `(foo() + "").length` may have a side effect
(#9605) (sapphi-red)
- 24d9261 minifier: Remove names from functions / classes in normal pass
to make the minifier idempotent (#9608) (sapphi-red)
- 6ac3635 napi/parser: Disable raw transfer on unsupported platforms
(#9651) (overlookmotel)
- cfdcfdb parser: Fix end span for optional binding pattern without type
annotation (#9652) (Boshen)
- 26da65d parser: Parse asi after class accessor property (#9623)
(Boshen)
- 87462fd parser: Fix end span for `using` declaration (#9622) (Boshen)
- 29edb51 transformer: Fix module runner transform of export default
expression (#9661) (hi-ogawa)

### Documentation

- 31a2618 allocator: Add safety constraint for
`String::from_raw_parts_in` (#9640) (overlookmotel)

### Refactor

- 44101bd allocator: Refactor and improve safty comments of
`String::from_strs_array_in` (#9639) (overlookmotel)
- c6edafe napi: Remove `npm/oxc-*/` npm packages (#9631) (Boshen)
- a43c341 semantic: Add `Scoping` to `Semantic` (#9614) (Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-03-11 12:05:56 +08:00
Boshen c6edafe08d refactor(napi): remove npm/oxc-*/ npm packages (#9631)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-03-09 22:43:06 +08:00
Boshen 0bbb197c87 ci(npm): rework release pipeline (#9581) 2025-03-07 11:49:50 +08:00
overlookmotel a9889f5c9a ci(benchmarks): benchmark NAPI parser (#9519)
Add benchmarks for NAPI parser. Benchmarks cover both "standard" mode and "raw transfer" mode.

Codspeed say they've sorted out the problems with wide variance in NodeJS benchmarks, so hopefully they won't wave all over the place, the way they did last year when we first tried to add these benchmarks.

What we also found last year is that Codspeed's measures didn't reflect real-world wallclock measurements at all when comparing code running on Rust side vs JS side. Raw transfer moves a lot of work from Rust side to JS side, and so likely the bench results will be misleading if comparing "standard" vs "raw".

I've added benchmarks for both, not to compare the 2, but because I think there's room to improve the performance of both "standard" and "raw" independently.
2025-03-05 02:21:01 +00:00
Arnaud Barré 8d7ceeeed4 ci(napi/transform): validate napi dts files (#9183)
---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2025-02-18 17:14:22 +08:00
Boshen df3eef81e6 chore(napi/parser): use vitest bench instead of tinybench (#9134)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-02-15 14:42:48 +08:00
overlookmotel ef553b92ad test(napi): add NAPI parser benchmark (#9045)
Add a quick benchmark for NAPI parser. It's included in our CI benchmarks, because likely will produce too much variance, but it's useful for local runs.
2025-02-11 14:09:46 +00:00
Boshen aa9d7e47ea build(napi): napi build --no-dts-cache (#8499) 2025-01-15 07:02:29 +00:00
Boshen 771c698a81 feat(oxc): remove oxc_napi crate (#7634)
napi has a limitation, it cannot feature gate type exposure.

closes #7623
2024-12-04 10:07:32 +08:00
Boshen 7c62a33a06 feat(napi/parser): return esm info (#7602)
The parser now returns import / export statement information, which can be used for parser plugins.
2024-12-03 11:21:54 +00:00
Boshen 24c585a20a feat(napi/parser): reexport @oxc-project/types (#7214)
closes #7207
2024-11-09 17:24:07 +08:00
Boshen fe28bae1e0 chore: remove unnecessary packageManager from package.json 2024-10-25 10:38:02 +08:00
ottomated 67a7bde4c6 feat(napi/parser)!: add typings to napi/parser (#6796)
- Added TypeScript annotation for `ParseResult.program`
- Modified the entrypoint for `oxc-parser` to allow wrapping the napi functions
- Updated `index.js` to parse the `program` string into a JSON object
- Updated tests
- Added a dependency on `@oxc/types`
2024-10-24 13:08:59 +00:00
Boshen 5b5daec392 refactor(napi): use vitest (#6307) 2024-10-06 02:57:48 +00:00
Boshen f5f3d08a51 build: use pnpm catalog 2024-09-07 13:15:43 +08:00
Boshen a03b24d94e ci: add napi tests (#5419) 2024-09-03 12:24:58 +08:00
Kevin Deng 三咲智子 bf49f339d0 chore: pin pnpm version & upgrade lockfile version (#5200) 2024-08-25 22:57:33 +08:00
Boshen 27cbd551fb chore: bump napi to v3 (#4365) 2024-07-19 14:06:33 +00:00
Boshen 0b8098a442 feat(napi): isolated-declaration (#3718) 2024-06-17 13:06:00 +00:00
Boshen b15bf2826b feat(napi/parser): remove experimental flexbuffer api (#2957) 2024-04-13 14:59:31 +08:00
overlookmotel 87348bd005 chore(napi): correct bench NPM script (#2786)
NAPI benchmarks now use Tinybench. NPM script was wrong.
2024-03-22 10:13:51 +00:00
overlookmotel 508091314f feat(tasks): benchmark NodeJS parser (#2770)
Add NodeJS parser to benchmarks.

Previous attempt #2724 did not work due CodSpeed producing very
inaccurate results (https://github.com/CodSpeedHQ/action/issues/96).

This version runs the actual benchmarks without CodSpeed's
instrumentation. Then another faux-benchmark runs within Codspeed's
instrumented action and just performs meaningless calculations in a loop
for as long as is required to take same amount of time as the original
uninstrumented benchmarks took.

It's unfortunate that we therefore don't get flame graphs on CodSpeed,
but this seems to be the best we can do for now.
2024-03-20 05:06:09 +00:00
overlookmotel af47aebc7c chore(napi): add oxc-parser to benchmarks (#2724)
Closes #2616.

Adds benchmarks for NodeJS NAPI build. Measurement includes `JSON.parse`
of the AST on JS side, since that's how it'll be used 99% of the time.

Benchmarks run against same files as Rust parser benchmarks, so we can
see the overhead of transferring AST to JS.
2024-03-15 19:45:02 +08:00
Boshen 32303b20fb New tool: oxc_module_lexer (#2650)
# Oxc Module Lexer

This is not a lexer. The name "lexer" is used for easier recognition.

## [es-module-lexer](https://github.com/guybedford/es-module-lexer)

Outputs the list of exports and locations of import specifiers,
including dynamic import and import meta handling.

Does not have any
[limitations](https://github.com/guybedford/es-module-lexer?tab=readme-ov-file#limitations)
mentioned in `es-module-lexer`.

I'll also work on the following cases to make this feature complete.

- [ ] get imported variables
https://github.com/guybedford/es-module-lexer/issues/163
- [ ] track star exports as imports as well
https://github.com/guybedford/es-module-lexer/issues/76
- [ ] TypeScript specific syntax
- [ ] TypeScript `type` import / export keyword

## [cjs-module-lexer](https://github.com/nodejs/cjs-module-lexer)

- [ ] TODO

## Benchmark

This is 2 times slower than `es-module-lexer`, but will be significantly
faster when TypeScript is processed.

The difference is around 10ms vs 20ms on a large file (700k).
2024-03-09 23:23:55 +08:00
Boshen 839e7c5c22 feat(napi/parser): add more linux-musl targets 2024-02-06 00:04:25 +08:00
Herrington Darkholme c63f5123b3 feat(parser/napi): add flexbuffer to AST transfer (2x speedup) (#1680)
Hi! I have created a proof of concept of improving using oxc in
JavaScript. The method is not polished but it provides valuable insights
for future direction!

Feel free to close~ It is for reference only :)

# Context 

This is a proof of concept implementation of passing binary AST to
JavaScript. JavaScript can selectively read flexbuffers-based AST nodes
on demand to avoid the deserialization toll. More context
[here](https://dev.to/herrington_darkholme/benchmark-typescript-parsers-demystify-rust-tooling-performance-2go8).

# Changes

* Add a `parseSyncBuffer` napi method to return a binary AST from Rust
to JavaScript. The AST is in flexbuffer format.
* Add a `test_buffer.js` to test usage of flexbuffers in JavaScript. It
is in cjs format because flexbuffers does not support ESM :/

# Result
Some preliminary results, for reference only.

```
~ node test_buffer.js
testJSON: 4.043s
testBuffer: 2.395s
```

Buffer based API is 100% faster than JSON.

# Future Ideas
* Flexbuffers itself is slow. A better binary protocol is desired!
* Using binary reader to traverse AST is undesirable. A proxy-based API
to emulate object behavior will be nice.
2023-12-15 02:52:33 +00:00
Boshen c202bc9dcb feat: Release resolver with NAPI (#1212) 2023-11-10 15:25:17 +00:00
Boshen 90ff0ddbe0 refactor: change @oxidation-compiler/napi to oxc-parser (#1209) 2023-11-10 06:17:05 +00:00