Commit graph

4506 commits

Author SHA1 Message Date
renovate[bot]
10b92dda1f
chore(deps): update dependency tar to v7.4.3 (#4516)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [tar](https://togithub.com/isaacs/node-tar) | [`7.4.0` ->
`7.4.3`](https://renovatebot.com/diffs/npm/tar/7.4.0/7.4.3) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/tar/7.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/tar/7.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/tar/7.4.0/7.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/tar/7.4.0/7.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>isaacs/node-tar (tar)</summary>

###
[`v7.4.3`](https://togithub.com/isaacs/node-tar/compare/v7.4.2...v7.4.3)

[Compare
Source](https://togithub.com/isaacs/node-tar/compare/v7.4.2...v7.4.3)

###
[`v7.4.2`](https://togithub.com/isaacs/node-tar/compare/v7.4.1...v7.4.2)

[Compare
Source](https://togithub.com/isaacs/node-tar/compare/v7.4.1...v7.4.2)

###
[`v7.4.1`](https://togithub.com/isaacs/node-tar/compare/v7.4.0...v7.4.1)

[Compare
Source](https://togithub.com/isaacs/node-tar/compare/v7.4.0...v7.4.1)

</details>

---

### Configuration

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

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, 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://www.mend.io/free-developer-tools/renovate/). View the
[repository job log](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-28 17:04:31 +00:00
Boshen
7446e986c3 feat(codegen): align more esbuild implementations (#4510) 2024-07-28 13:35:37 +00:00
Boshen
35654e665c feat(codegen): align operator precedence with esbuild (#4509)
closes #4339
2024-07-28 11:48:51 +00:00
Boshen
6a94e3f573 fix(codegen): fixes for esbuild test cases (#4503) 2024-07-28 08:57:15 +00:00
Dunqing
b1b66e2a28 Revert "fix(website): incorrect reference displayed" (#4506)
Reverts oxc-project/oxc#4453

https://github.com/oxc-project/oxc/issues/4467 changes reference_id to zero-based index 😅
2024-07-28 01:58:50 +00:00
oxc-bot
80118cbf3b
Release crates v0.22.1 (#4508)
## [0.22.1] - 2024-07-27

### Features

- 2477330 ast: Add `AstKind::TSExportAssignment` (#4501) (Dunqing)
- aaee07e ast: Add `AstKind::AssignmentTargetPattern`,
`AstKind::ArrayAssignmentTarget` and `AstKind::ObjectAssignmentTarget`
(#4456) (Dunqing)
- fd363d1 ast: Add AstKind::get_container_scope_id (#4450) (DonIsaac)
- e2735ca span: Add `contains_inclusive` method (#4491) (DonIsaac)

### Bug Fixes

- 368112c ast: Remove `#[visit(ignore)]` from
`ExportDefaultDeclarationKind`'s `TSInterfaceDeclaration` (#4497)
(Dunqing)
- 36bb680 semantic: `TSExportAssignment` cannot reference type binding
(#4502) (Dunqing)
- cb2fa49 semantic: `typeof` operator cannot reference type-only import
(#4500) (Dunqing)
- ef0e953 semantic: Generic passed to typeof not counted as a reference
(#4499) (Dunqing)
- 40cafb8 semantic: Params in `export default (function() {})` flagged
as `SymbolFlags::Export` (#4480) (Dunqing)
- 2e01a45 semantic: Non-exported namespace member symbols flagged as
exported (#4493) (Don Isaac)
- e4ca06a semantic: Incorrect symbol’s scope_id after var hoisting
(#4458) (Dunqing)
- 77bd5f1 semantic: Use correct span for namespace symbols (#4448) (Don
Isaac)
- 5db7bed sourcemap: Fix pre-calculation of required segments for
building JSON (#4490) (overlookmotel)
- 1667491 syntax: Correct `is_reserved_keyword_or_global_object`'s
incorrect function calling. (#4484) (Ethan Goh)
- 82ba2a0 syntax: Fix unsound use of `NonZeroU32` (#4466)
(overlookmotel)
- c04b9aa transformer: Add to `SymbolTable::declarations` for all
symbols (#4460) (overlookmotel)
- ecdee88 transformer/typescript: Incorrect eliminate exports when the
referenced symbol is both value and type (#4507) (Dunqing)

### Performance

- 963a2d1 mangler: Reduce unnecessary allocation (#4498) (Dunqing)
- 868fc87 parser: Optimize conditional advance on ASCII values (#4298)
(lucab)
- 24beaeb semantic: Give `AstNodeId` a niche (#4469) (overlookmotel)
- 348c1ad semantic: Remove `span` field from `Reference` (#4464)
(overlookmotel)
- 6a9f4db semantic: Reduce storage size for symbol redeclarations
(#4463) (overlookmotel)
- 705e19f sourcemap: Reduce memory copies encoding JSON (#4489)
(overlookmotel)
- 4d10c6c sourcemap: Pre allocate String buf while encoding (#4476)
(Brooooooklyn)

### Documentation

- f5f0ba8 ast: Add doc comments to more AST nodes (#4413) (Don Isaac)
- 871b3d6 semantic: Add doc comments for SymbolTester and SemanticTester
(#4433) (DonIsaac)

### Refactor

- 9c5d2f9 ast/builder: Use `Box::new_in` over `.into_in` (#4428)
(overlookmotel)
- ccb1835 semantic: Methods take `Span` as param, not `&Span` (#4470)
(overlookmotel)
- f17254a semantic: Populate `declarations` field in
`SymbolTable::create_symbol` (#4461) (overlookmotel)
- a49f491 semantic: Re-order `SymbolTable` fields (#4459)
(overlookmotel)
- 7cd53f3 semantic: Var hoisting (#4379) (Dunqing)
- 4f5a7cb semantic: Mark SemanticTester and SymbolTester as must_use
(#4430) (DonIsaac)
- c958a55 sourcemap: `push_list` method for building JSON (#4486)
(overlookmotel)
- c99b3eb syntax: Give `ScopeId` a niche (#4468) (overlookmotel)
- 96fc94f syntax: Use `NonMaxU32` for IDs (#4467) (overlookmotel)

### Testing

- 4b274a8 semantic: Add more test cases for symbol references (#4429)
(DonIsaac)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-07-28 09:58:29 +08:00
Dunqing
ecdee88cfb
fix(transformer/typescript): incorrect eliminate exports when the referenced symbol is both value and type (#4507) 2024-07-27 12:11:29 -04:00
Dunqing
963a2d1b85 perf(mangler): reduce unnecessary allocation (#4498)
There seems to be no noticeable change in performance.
2024-07-27 10:55:49 +00:00
overlookmotel
5db7bed4f5 fix(sourcemap): fix pre-calculation of required segments for building JSON (#4490)
Fix the maths for calculating max number of segments required when building JSON source map.
2024-07-27 10:25:42 +00:00
overlookmotel
705e19f794 perf(sourcemap): reduce memory copies encoding JSON (#4489)
Reduce memory copies when encoding source map as JSON, extending approach taken in #4476 to also avoid memory copies for source texts.

I believe reason this shows no benefit on benchmarks is because our benchmarks only create a source map from a single source file, but it should result in a speed-up when there are multiple sources.
2024-07-27 10:25:40 +00:00
overlookmotel
c958a557fe refactor(sourcemap): push_list method for building JSON (#4486)
Follow up after #4476. Refactor to remove repeated code.
2024-07-27 10:25:38 +00:00
Dunqing
36bb6805c6 fix(semantic): TSExportAssignment cannot reference type binding (#4502)
close: #4488
2024-07-27 04:55:03 +00:00
Dunqing
2477330440 feat(ast): add AstKind::TSExportAssignment (#4501)
part of #4488
2024-07-27 04:55:02 +00:00
Dunqing
cb2fa4924e
fix(semantic): typeof operator cannot reference type-only import (#4500) 2024-07-27 00:21:06 -04:00
Dunqing
ef0e953702
fix(semantic): generic passed to typeof not counted as a reference (#4499) 2024-07-27 00:16:25 -04:00
Dunqing
40cafb8c61 fix(semantic): params in export default (function() {}) flagged as SymbolFlags::Export (#4480)
The code changes in `builder.rs` optimize the export flag check in the `SemanticBuilder` implementation. Instead of setting the export flag to `true` for all cases except `ExportDefaultDeclarationKind::ClassDeclaration(ref class)`, the flag is now set to `true` only for `ExportDefaultDeclarationKind::ClassDeclaration` and `false` for all other cases. This change improves the efficiency of the export flag check.
2024-07-27 02:42:24 +00:00
Dunqing
368112c9ac fix(ast): remove #[visit(ignore)] from ExportDefaultDeclarationKind's TSInterfaceDeclaration (#4497)
I can't find any reason to add `#[visit(ignore)]` there
2024-07-27 02:11:54 +00:00
Don Isaac
f5f0ba8c33
docs(ast): add doc comments to more AST nodes (#4413) 2024-07-26 21:21:35 -04:00
lucab
868fc87885 perf(parser): optimize conditional advance on ASCII values (#4298)
Part of https://github.com/oxc-project/oxc/issues/3291.
2024-07-27 01:17:25 +00:00
DonIsaac
e2735ca2c5 feat(span): add contains_inclusive method (#4491)
Part of #4445, broken into a separate PR.
2024-07-27 01:05:08 +00:00
Don Isaac
2e01a45b2b
fix(semantic): non-exported namespace member symbols flagged as exported (#4493)
> Part of #4445

Fixes a bug where non-exported functions and variables inside of
exported TS namespaces were being flagged with `SymbolFlags::Export`

```ts
export namespace Foo {
  // incorrectly flagged as exported
  function foo() { }
}
```
2024-07-27 08:46:21 +08:00
overlookmotel
f3aedf6501 chore: remove .idea from .gitignore (#4496)
`.idea` snuck its way into `.gitignore` in #4484. Remove it again.

See #4355 for reason why it shouldn't be there.
2024-07-26 23:59:24 +00:00
Ethan Goh
1667491868
fix(syntax): correct is_reserved_keyword_or_global_object's incorrect function calling. (#4484)
It may be a problem, but doesn't matter previously.

Formerly, the `is_reserved_keyword_or_global_object` is
`is_reserved_keyword(s) || is_reserved_keyword(s)`. I think it should be
`is_reserved_keyword(s) || is_global_object(s)` according to its name.

Also, the `.idea` may be because I am using RustRover, which may
automatically create `.idea` folder. So I ignore it in `.gitignore`.

I think I can contribute to `oxc` more when I am free.
2024-07-26 17:20:10 -04:00
overlookmotel
5c40dadb14 chore: order dependencies in Cargo.toml (#4482)
Order dependencies in `Cargo.toml` in alphabetical order.
2024-07-26 14:20:28 +00:00
Brooooooklyn
4d10c6c9be
perf(sourcemap): pre allocate String buf while encoding (#4476)
I'm trying llama3.1:70b following [local-ai-copilot](https://developer.ibm.com/tutorials/awb-local-ai-copilot-ibm-granite-code-ollama-continue/) to find some potential performance improvement.

The code was not completed by AI; it only identified potential optimizations, which I am testing for effectiveness.
2024-07-26 13:58:09 +00:00
overlookmotel
42a2519b40
ci: run benchmarks on rust-toolchain.toml changes (#4479)
Upgrading to Rust 1.80.0 (#4474) regressed some benchmarks (#4478). We
didn't notice because benchmarks didn't run on the PR. Make benchmarks
run on changes to `rust-toolchain.toml` so we'll be alerted if this
happens again on any future updates.
2024-07-26 11:33:41 +01:00
renovate
0c134422ba chore(deps): update dependency rust to v1.80.0 (#4474)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [rust](https://togithub.com/rust-lang/rust) | minor | `1.79.0` -> `1.80.0` |

---

### Release Notes

<details>
<summary>rust-lang/rust (rust)</summary>

### [`v1.80.0`](https://togithub.com/rust-lang/rust/compare/1.79.0...1.80.0)

[Compare Source](https://togithub.com/rust-lang/rust/compare/1.79.0...1.80.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, 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://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
2024-07-26 01:26:44 +00:00
overlookmotel
b60bdf1ff7 perf(linter): no_shadow_restricted_names only look up name in hashmap once (#4472)
`eslint(no_shadow_restricted_names)` lint rule emits a diagnostic for every declaration of a symbol with a restricted name.

Currently for a var which has redeclarations, the var name is looked up in hash map of restricted names repeatedly for each redeclaration. This PR changes that to only do a single hashmap lookup.

Also, if the var name is `undefined`, skip looking it up in hash map, because we already know it's a restricted name.
2024-07-26 01:30:06 +01:00
overlookmotel
ccb1835a45 refactor(semantic): methods take Span as param, not &Span (#4470)
`Span` is `Copy` and 8 bytes. So better to pass `Span` to functions, rather than `&Span` (which is also 8 bytes, but involves the indirection of a reference).
2024-07-26 00:14:56 +00:00
overlookmotel
24beaeb4ee perf(semantic): give AstNodeId a niche (#4469)
Make `AstNodeId` a type with a niche, using `NonMaxU32` as its internal storage. This makes `Option<AstNodeId>` 4 bytes instead of 8. That halves the size of the `Vec` for parent IDs in `AstNodes` (which gets pretty big).
2024-07-26 00:14:53 +00:00
overlookmotel
c99b3eb464 refactor(syntax): give ScopeId a niche (#4468)
Make `ScopeId` a type with a niche, like `SymbolId` and `ReferenceId`. This makes `Option<ScopeId>` 4 bytes instead of 8, and shrinks various AST types e.g. `ArrowFunctionExpression` by 8 bytes, and halves the size of the `Vec` in `ScopeTree::parent_ids`.

The snapshot change on `prefer-hooks-in-order` lint rule appears incidental - it doesn't alter what errors are reported, only the order they're reported in. This appears to be because it changes the order of keys in a hashmap keyed by `ScopeId` that [the rule uses](a49f4915de/crates/oxc_linter/src/rules/jest/prefer_hooks_in_order.rs (L143)).
2024-07-26 00:14:50 +00:00
overlookmotel
96fc94f61e refactor(syntax): use NonMaxU32 for IDs (#4467)
`SymbolId` and `ReferenceId` are stored as `NonZeroU32`, but with a wrapper to make `u32::MAX` the illegal value, instead of `0`.

Use the existing `nonmax` crate for this. Our current implementation uses `idx + 1` to avoid the zero value, whereas `nonmax` crate uses XOR `idx ^ u32::MAX`, which is a cheaper operation.

Initially I made this change manually instead of pulling in a dependency, but it's a pain because it requires implementing `Debug` and `PartialOrd` by hand to handle the difference between the "actual" value and its stored representation. So I thought better to use a crate which does this for us.
2024-07-26 00:14:47 +00:00
overlookmotel
82ba2a073f fix(syntax): fix unsound use of NonZeroU32 (#4466)
`NonZeroU32::new_unchecked(idx as u32 + 1)` is unsound because if `idx == u32::MAX`, `idx + 1` wraps around back to zero. So unfortunately we need to use the checked version `NonZeroU32::new(idx as u32 + 1).unwrap()` to avoid UB in this edge case.
2024-07-26 00:14:44 +00:00
overlookmotel
81384f5059 perf(linter): avoid unnecessary work in nextjs:no_duplicate_head rule (#4465)
In `nextjs:no_duplicate_head` rule, avoid allocating a `Vec` unless more than one `<Head>` is found (uncommon case).

Also, #4464 made getting span of a `Reference` a little more expensive. Avoid this work unless it's needed (which it generally won't be).
2024-07-26 00:14:41 +00:00
overlookmotel
348c1ade96 perf(semantic): remove span field from Reference (#4464)
Remove `span` field from `Reference`. Span can instead be got via looking up span on `AstKind` via `reference.node_id`.

This shrinks `Reference` from 20 bytes to 12 bytes.

It does make getting span of a `Reference` a bit slower, as there's an extra table lookup involved, but the only places this is needed is in linter, and almost always when generating a diagnostic (i.e. cold path).
2024-07-26 00:14:38 +00:00
overlookmotel
6a9f4db609 perf(semantic): reduce storage size for symbol redeclarations (#4463)
Most symbols don't have redeclarations.

So instead of storing `Vec<Span>` directly in `redeclare_variables` (24 bytes per symbol), store `Option<RedeclarationId>` (4 bytes).

`RedeclarationId` indexes into `redeclarations` where the actual `Vec<Span>` is stored. But for symbols with no redeclarations (the vast majority), it takes 4 bytes per symbol only.
2024-07-26 00:14:35 +00:00
overlookmotel
f17254ae2a refactor(semantic): populate declarations field in SymbolTable::create_symbol (#4461)
`declarations` field of `SymbolTable` is part of SoA group, where all `Vec`s in the group are indexed by `SymbolId`. Populate `declarations` field along with the rest in `create_symbol`, to prevent them getting out of sync. This will prevent bugs like the one fixed in #4460.
2024-07-26 00:14:32 +00:00
overlookmotel
c04b9aa5db fix(transformer): add to SymbolTable::declarations for all symbols (#4460)
`declarations` field of `SymbolTable` is part of the SoA group field. For it to be valid to index into with `SymbolId`, an entry must be added for every new symbol which is created.
2024-07-26 00:14:29 +00:00
overlookmotel
a49f4915de refactor(semantic): re-order SymbolTable fields (#4459)
Group the fields which are SoA indexed by `ScopeId` together.
2024-07-25 14:38:36 +00:00
Dunqing
e4ca06ae8c
fix(semantic): incorrect symbol’s scope_id after var hoisting (#4458)
Bug found in https://github.com/rolldown/rolldown/pull/1726
2024-07-25 21:12:26 +08:00
Boshen
e1ca4122d8 chore(codegen): port over esbuild codegen tests (all ignored right now) (#4457) 2024-07-25 10:00:34 +00:00
Dunqing
aaee07e170 feat(ast): add AstKind::AssignmentTargetPattern, AstKind::ArrayAssignmentTarget and AstKind::ObjectAssignmentTarget (#4456)
close: #4435
2024-07-25 09:32:33 +00:00
cinchen
e3b0c4066a
feat(linter): eslint-plugin-vitest/no-identical-title (#4422)
support
[eslint-plugin-vitest/no-identical-title](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md)

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-07-25 00:24:19 -04:00
Dunqing
855f2f6286
fix(website): incorrect reference displayed (#4453)
close: #4447
2024-07-24 23:13:18 -04:00
Don Isaac
77bd5f102c
fix(semantic): use correct span for namespace symbols (#4448)
Before:
```ts
    namespace N {}
// ---------------
```

After:
```ts
    namespace N {}
//            -
```

Found while working on #4427
2024-07-25 09:43:06 +08:00
Dunqing
7cd53f3897 refactor(semantic): var hoisting (#4379)
close: #4323

This PR refactors the var hoisting logic to avoid inserting the same symbol into every scope that can be hosted.
2024-07-25 00:55:02 +00:00
DonIsaac
fd363d1c8b feat(ast): add AstKind::get_container_scope_id (#4450)
Part of #4445
2024-07-25 00:51:00 +00:00
DonIsaac
871b3d6135 docs(semantic): add doc comments for SymbolTester and SemanticTester (#4433) 2024-07-24 16:58:13 +00:00
DonIsaac
4f5a7cbf3c refactor(semantic): mark SemanticTester and SymbolTester as must_use (#4430) 2024-07-24 16:58:11 +00:00
DonIsaac
4b274a8e6f test(semantic): add more test cases for symbol references (#4429) 2024-07-24 16:58:09 +00:00