Commit Graph

811 Commits

Author SHA1 Message Date
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
Copilot 7332ae4e62 feat(ast)!: Box rest fields of ArrayAssignmentTarget and ObjectAssignmentTarget (#12698) 2025-08-01 12:28:41 +08:00
oxc-bot 5ff286a57a release(crates): v0.79.1 (#12655) 2025-07-31 16:13:45 +08:00
oxc-bot 0fa9b8a8ab release(crates): v0.79.0 (#12600) 2025-07-30 10:31:53 +08:00
overlookmotel 8717807619 refactor(napi/oxlint): make types.js importable (#12581)
Pure refactor. Alter format of `types.js` generated code, so it can be `import`ed.
2025-07-29 09:37:04 +00:00
overlookmotel 69f8b63911 perf(napi/parser, napi/oxlint): lazy visit: faster check for exit visitor (#12496)
In the absence of benchmarks, I don't know for sure that this is a perf improvement. But I assume so.

`if (exit)` requires coercion of `exit` to a boolean, whereas `if (exit !== null)` is a simpler check - comparison to a single known constant.

Once we have reliable benchmarking set up for raw transfer, we can revisit and tweak the code in many ways, but I think in the meantime this change is *probably* an improvement.
2025-07-24 10:26:57 +00:00
overlookmotel f0b1f0d485 refactor(napi/oxlint, napi/parser): remove source length from RawTransferMetadata (#12483)
Refactor to oxlint JS plugins and raw transfer. Remove source text length field from `RawTransferMetadata`. It's not necessary - source text is part of `Program`, so the length can be obtained from there, it doesn't need to be duplicated.
2025-07-24 08:54:16 +00:00
oxc-bot ccf1fb4241 release(crates): v0.78.0 (#12486) 2025-07-24 12:02:16 +08:00
renovate[bot] bb8c635b5c chore(deps): update dependency @napi-rs/wasm-runtime to v1 (#12412) 2025-07-21 08:54:02 +08:00
oxc-bot 11cad7d0f6 release(crates): v0.77.3 (#12407) 2025-07-20 22:34:27 +08:00
Boshen fa2d3f1481 chore(deps): napi v3 (#12388) 2025-07-18 11:45:19 +00:00
overlookmotel c5dff1ec98 refactor(linter, napi/parser): add source_len field to RawTransferMetadata (#12383)
Add a field `source_len` to `RawTransferData`, which stores the byte length of source text.

In `napi/parser`, this wasn't required, as the source text is passed in from JS side, so JS already knows how long it is. But in linter, source text passes in the opposite direction, so Rust needs to tell JS it's length. It will do so by recording it in this field, and JS reads it from the buffer.
2025-07-18 08:59:32 +00:00
overlookmotel 5e3b415903 refactor(linter): duplicate RawTransferMetadata in oxc_linter crate (#12382)
`RawTransferMetadata` is used to store basic info about the data in the buffer which is used on JS side to locate `Program` in the buffer etc.

This struct lives in `napi/parser` crate but we're going to need it in `napi/oxlint2` too. So make a 2nd copy of it in `napi/oxlint2` and use `oxc_ast_tools` to enforce that the 2 copies are identical.

This is a bit of a hack, but it doesn't seem worthwhile creating a new crate just to hold this one struct, and it doesn't really fit in `oxc_allocator`, or any of our other existing crates.
2025-07-18 08:59:32 +00:00
overlookmotel bc0fbe5195 feat(allocator): AllocatorPool store IDs in Allocators (#12310)
Fixed size allocator pool give each `Allocator` a unique ID and store it in `FixedSizeAllocatorMetadata` struct at end of the buffer. This prepares the way for sharing buffers created on Rust side with JS while avoiding use-after-free or double-free.
2025-07-18 08:59:31 +00:00
overlookmotel 319fc3b817 refactor(allocator/fixed-size): store alloc_ptr in the memory block backing the allocator (#12380)
`FixedSizeAllocator`s allocate a block of memory larger than what the `Allocator` controls, and often with a different start pointer. So when `FixedSizeAllocator` is dropped, it needs to deallocate that block of memory using the original pointer.

That pointer way previously stored in `FixedSizeAllocator` itself. Instead store it in a `FixedSizeAllocatorMetadata` struct, which is written into the memory block itself, after the section controlled by the `Allocator`, and other metadata (`RawTransferMetadata`).

This allows getting the original `alloc_ptr` when you only have access to the `Allocator`, but not the `FixedSizeAllocator`.
2025-07-18 08:59:31 +00:00
overlookmotel 8fe1aeca1f refactor(ast_tools, allocator, napi/parser): rename vars (#12379)
Just rename variables, to prepare for substantive changes in following PRs.
2025-07-18 08:59:31 +00:00
oxc-bot f4e06c89ab release(crates): v0.77.2 (#12372) 2025-07-17 23:40:00 +08:00
overlookmotel 4517624742 refactor(napi/parser): use sourceByteLen for UTF8 source length (#12365)
Pure refactor. Use var name `sourceByteLen` for UTF-8 byte length of source, to disambiguate from UTF-16 length (`sourceText.length`).
2025-07-17 13:55:32 +00:00
oxc-bot ab68d5c7b4 release(crates): v0.77.1 (#12319) 2025-07-16 19:28:15 +08:00
overlookmotel a2da6827da refactor(napi/parser): clarify pointer maths (#12300)
Correct comment for `get_buffer_offset` (used by raw transfer) about buffer size, and add an additional rounding down. The latter makes no difference because the offset is truncated to `u32` straight after anyway, but better to code defensively in case we change buffer size / alignment later on.
2025-07-15 15:09:52 +00:00
overlookmotel 2f9bd1116a refactor(allocator): fixed size allocator leave space for metadata after arena (#12278)
`FixedSizeAllocator` create an inner `Allocator` 16 bytes smaller than the buffer size. The last 16 bytes will be used to store `RawTransferMetadata` (offset of the AST data etc). This prepares `FixedSizeAllocator` for use with raw transfer for JS linter plugins.
2025-07-14 20:46:41 +00:00
overlookmotel cc1e9fcccf perf(napi/parser): raw transfer: reduce size of buffer by 16 bytes (#12277)
Reduce the size of the buffer used for raw transfer by 16 bytes so that there's 16 bytes space for `malloc`'s metadata without committing another memory page. I don't know for sure that `malloc` would store metadata in the allocation for allocations this large, but this is what Bumpalo does, so it's probably a good idea.
2025-07-14 20:46:41 +00:00
overlookmotel 5fba91cfb1 refactor(napi/parser): raw transfer: introduce metadata struct (#12269)
Pure refactor. Introduce a `RawTransferMetadata` struct to hold metadata that gets written to end of buffer. Codegen use knowledge of memory layout of this struct to generate constants added in #12268. This is more robust than manually calculating offsets.
2025-07-14 19:36:49 +00:00
overlookmotel 39ef911147 refactor(napi/parser, allocator): raw transfer: store buffer size and align as consts (#12275)
Similar to #12268. Instead of hard-coding the size and alignment of raw transfer buffers in multiple places, codegen add these to generated files, and everywhere else import the values from those files. This is more robust.
2025-07-14 19:36:49 +00:00
overlookmotel d009bdb886 refactor(napi/parser): raw transfer: store offsets as consts (#12268)
Pure refactor. Instead of hard-coding constants for fixed offsets of data in the buffer, generate these constants in one place and import them from `constants.js` everywhere else.
2025-07-14 18:56:27 +00:00
overlookmotel 28be5de1dd perf(napi/parser): raw transfer: move check for supported platform (#12274)
Small optimization to raw transfer. Move check that running on a supported platform out of `prepareRaw` function (which runs on every call to `parseSync`) to top level (so we only do the check once). This module is lazy-loaded if user calls `parseSync` with `experimentalRawTransfer`, so the check won't run if user is not using raw transfer.
2025-07-14 18:56:27 +00:00
overlookmotel 43f61ed4eb refactor(napi/parser): correct comment about raw transfer buffer size (#12273)
Correct and update comment about the buffer size used by raw transfer, and why we use that size.
2025-07-14 18:47:03 +00:00
overlookmotel 28ed99b830 refactor(napi/parser): do not compile raw transfer code on WASM (#12271)
Reduce size of `oxc-parser` WASM binary by omitting code for raw transfer. Raw transfer is not supported on WASM.

This also allows removing the workaround to prevent compilation failure on 32-bit systems due to `1 << 32` overflowing `usize`. This code is no longer compiled on 32-bit systems.
2025-07-14 18:11:06 +00:00
Boshen 9b14fbcd4f feat(ast): add ThisExpression to TSTypeName (#12156)
part of #12042

Aligned with estree: https://github.com/typescript-eslint/typescript-eslint/blob/5c5e3d5c3853ab613e06be0d77a40e970017b3fc/packages/ast-spec/src/unions/EntityName.ts#L5
2025-07-13 01:43:57 +00:00
oxc-bot 95b13e8c00 release(crates): v0.77.0 (#12234) 2025-07-12 10:15:34 +08:00
overlookmotel 4c35f4abb6 perf(napi/parser): optimize raw transfer deserializer for TSClassImplements (#12158)
Reduce property lookups in deserializer.
2025-07-09 12:23:08 +00:00
Boshen 407429a09c feat(napi/parser,napi/transform): accept lang=dts (#12154) 2025-07-09 09:13:18 +00:00
camc314 baa372641e refactor(tests/napi): add build-test script for tests (#12132) 2025-07-08 17:08:14 +00:00
oxc-bot 671b596ab1 release(crates): v0.76.0 (#12125) 2025-07-08 17:33:59 +08:00
overlookmotel a490e0060a fix(napi/parser): lazy visit: correct error messages (#12109)
Fix typos.
2025-07-07 05:48:00 +00:00
overlookmotel c5e8d906ad refactor(napi/parser): lazy deser: constructors.js export static object (#12090)
Pure refactor. `constructors.js` export a statically-constructed object, rather than adding properties to an initially empty object. This should make it faster for JS engine to fetch properties of that object.
2025-07-06 11:29:06 +00:00
overlookmotel fe35285017 refactor(napi/parser): lazy deser: remove construct function (#12089)
Pure refactor. Remove `construct` function, and instead construct `RawTransferData` class in the call site. `constructors.js` can now only export an object containing the constructor classes.
2025-07-06 11:29:05 +00:00
overlookmotel 9ae081590d refactor(napi/parser): move files (#12088)
Pure refactor. Move generated files for lazy deserialization into a separate directory from generated files for raw transfer.
2025-07-06 11:29:05 +00:00