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 )
...
[](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
overlookmotel
9c5d2f9d6a
refactor(ast/builder): use Box::new_in over .into_in ( #4428 )
...
In `AstBuilder`'s `alloc_*` methods, use `Box::new_in` instead of `.into_in`. This is more explicit, so I feel easier to understand. It may also make life easier for compiler by not requiring it to perform type coercion.
2024-07-24 16:34:32 +00:00
Dunqing
46cf7179a4
chore(semantic): fix incorrect reference id in snapshot ( #4441 )
2024-07-24 12:51:57 +00:00
oxc-bot
aa56eb4d1d
Release crates v0.22.0 ( #4434 )
...
## [0.22.0] - 2024-07-23
- 85a7cea semantic: [**BREAKING**] Remove name from `reference` (#4329 )
(Dunqing)
- f68b659 ast: [**BREAKING**] Reorder fields of
`ArrowFunctionExpression` (#4364 ) (Dunqing)
### Features
- d345b84 ast: Add `#[ast]` attribute to non-visited AST types. (#4309 )
(rzvxa)
- 3c0c709 linter: Add typescript-eslint/no-extraneous-class (#4357 )
(Jaden Rodriguez)
- 68efcd4 linter/react-perf: Handle new objects and arrays in prop
assignment patterns (#4396 ) (DonIsaac)
- 0deb027 minfier: Dce `if (xxx) else if (false) { REMOVE }` (#4407 )
(Boshen)
- e33ec18 minifier: Compress `typeof foo == "undefined"` into `typeof
foo > "u"` (#4412 ) (Boshen)- 6068e6b Add error codes to OxcDiagnostic
(#4334 ) (DonIsaac)
### Bug Fixes
- aece1df ast: Visit `Program`s `hashbang` field first (#4368 )
(overlookmotel)
- 44a10c4 codegen: Object shorthand with parens `({x: (x)})` -> `({ x
})` (#4391 ) (Boshen)
- 3d88f20 codegen: Print shorthand for all `{ x }` variants (#4374 )
(Boshen)
- e624dff codegen,mangler: Do not print shorthand for `ObjectProperty`
(#4350 ) (Boshen)
- ac08de8 linter/react_perf: Allow new objects, array, fns, etc in top
scope (#4395 ) (DonIsaac)
- 267f7c4 minifier: Skip `Object.defineProperty(exports, ...)` for
`cjs-module-lexer` (#4409 ) (Boshen)
- bc8d4e5 semantic: Correct comment (#4410 ) (overlookmotel)
- 6ffce86 semantic: Align `visit_arrow_function_expression` field visit
order with ast (#4366 ) (Dunqing)
- 4cd5df0 sourcemap: Avoid negative line if token_chunks has same
prev_dst_line (#4348 ) (underfin)
- f8565ae transformer/typescript: Unexpectedly removed class binding
from ExportNamedDeclaration (#4351 ) (Dunqing)- ea33f94 Impl
PartialEq<str> for CompactStr (#4352 ) (DonIsaac)
### Performance
- 1b51511 semantic: Use `Atom` instead of `CompactStr` for
`UnresolvedReferencesStack` (#4401 ) (Dunqing)
- 40f9356 semantic: Calculate number of nodes, scopes, symbols,
references before visiting AST (#4367 ) (Dunqing)
- da13d93 semantic: Remove bounds checks on unresolved references stack
(#4390 ) (overlookmotel)
- e70c67b semantic: Remove a branch from `add_scope` (#4384 )
(overlookmotel)
- 402006f semantic: Simplify logic in `enter_scope` + `leave_scope`
(#4383 ) (overlookmotel)
- 7469e01 semantic: Remove branch from `Nodes::add_node` (#4361 )
(overlookmotel)
- 7eb2864 traverse: Speed up finding UID binding name (#4356 )
(overlookmotel)- a207923 Replace some CompactStr usages with Cows
(#4377 ) (DonIsaac)
### Refactor
- 504daed allocator: Rename fn params for `Box::new_in` (#4431 )
(overlookmotel)
- d213773 ast: Replace serde rename "lowercase" with "camelCase" (#4376 )
(overlookmotel)
- abfccbd ast: Reduce `#[cfg_attr]` boilerplate in AST type defs (#4375 )
(overlookmotel)
- 5f1c7ec ast: Rename the `visited_node` marker to `ast`. (#4289 )
(rzvxa)
- 58f6ec2 ast: Enter node before scope (#4347 ) (Dunqing)
- 59aea73 ast: Scope is created only if CatchClause has param (#4346 )
(Dunqing)
- 7a3e925 ast_codegen: Better visit marker parsing. (#4371 ) (rzvxa)
- 0e1ea90 isolated-declarations: Remove useless code from scope (#4420 )
(Dunqing)
- 7a75e0f linter: Use diagnostic codes in lint rules (#4349 ) (DonIsaac)
- a2eabe1 parser: Use error codes for ts diagnostics (#4335 ) (DonIsaac)
- 5d77b36 semantic: `visit_program` visit `hashbang` field (#4370 )
(overlookmotel)
- f7b9ada semantic: `Program` visitor leave scope before node (#4369 )
(overlookmotel)
- 729b288 semantic: Shorten code (#4358 ) (overlookmotel)
- 21d0eee semantic: Use error codes for ts diagnostics (#4336 )
(DonIsaac)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-07-24 08:23:27 +08:00
DonIsaac
e8071e3db4
feat(syntax): add boolean check methods for typescript-related symbol flags ( #4426 )
2024-07-23 22:23:08 +00:00
overlookmotel
0677a91e14
refactor(allocator): make Box::new_in code more explicit ( #4432 )
...
Replace `.into` with `NonNull::from`. I feel this is a bit clearer.
2024-07-23 15:41:31 +00:00
overlookmotel
504daeda24
refactor(allocator): rename fn params for Box::new_in ( #4431 )
...
Rename function params for `Box::new_in` to be more descriptive and match our naming conventions.
2024-07-23 15:24:30 +00:00
Boshen
9e301755ea
ci: pass secret to reusable workflow
2024-07-23 22:50:50 +08:00
Boshen
4246a21c6d
ci: run cargo check before cargo release-oxc
2024-07-23 22:25:40 +08:00
Boshen
52f65e976d
ci: remove top level env
2024-07-23 22:24:10 +08:00
Boshen
f005416bc3
ci: run cargo check in prepare_release_crates
2024-07-23 22:18:46 +08:00
Boshen
fb15a19040
chore: fix cyclic dependencies by moving mangler tests to oxc_minifier
2024-07-23 22:13:13 +08:00
Boshen
6beef7414c
ci: add check job (publish --dry-run) in prepare_release_crates
2024-07-23 22:05:21 +08:00
Boshen
269151d7f0
ci: use bot account with PAT in reusable_prepare_release
2024-07-23 22:01:41 +08:00
cinchen
c9367820ef
feat(linter): eslint-plugin-vitest/no-conditional-expect ( #4425 )
...
support
[eslint-plugin-vitest/no-conditional-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md )
2024-07-23 21:50:45 +08:00
cinchen
27fdd69448
feat(linter): eslint-plugin-vitest/no-commented-out-tests ( #4424 )
2024-07-23 08:52:39 -04:00
Dunqing
0e1ea90282
refactor(isolated-declarations): remove useless code from scope ( #4420 )
...
The original logic was written to fix incorrect TypeScript ast scopes. Now the scopes are correct so they can be removed
2024-07-23 09:39:16 +00:00
Dunqing
25dab7b1ac
Revert "chore: fix failed publish caused by cyclic dev dependencies " ( #4419 )
...
Reverts oxc-project/oxc#4416
This trick doesn't work for crates that have circular dependencies on
each other that all need to be published!
2024-07-23 15:56:42 +08:00
Dunqing
426016d1d6
Revert "Release crates v0.22.0" ( #4418 )
...
Still release failed. Reverts oxc-project/oxc#4417
2024-07-23 15:51:01 +08:00
github-actions[bot]
f76113cd8f
Release crates v0.22.0 ( #4417 )
...
## [0.22.0] - 2024-07-23
- 85a7cea semantic: [**BREAKING**] Remove name from `reference` (#4329 )
(Dunqing)
- f68b659 ast: [**BREAKING**] Reorder fields of
`ArrowFunctionExpression` (#4364 ) (Dunqing)
### Features
- d345b84 ast: Add `#[ast]` attribute to non-visited AST types. (#4309 )
(rzvxa)
- 3c0c709 linter: Add typescript-eslint/no-extraneous-class (#4357 )
(Jaden Rodriguez)
- 68efcd4 linter/react-perf: Handle new objects and arrays in prop
assignment patterns (#4396 ) (DonIsaac)
- 0deb027 minfier: Dce `if (xxx) else if (false) { REMOVE }` (#4407 )
(Boshen)
- e33ec18 minifier: Compress `typeof foo == "undefined"` into `typeof
foo > "u"` (#4412 ) (Boshen)- 6068e6b Add error codes to OxcDiagnostic
(#4334 ) (DonIsaac)
### Bug Fixes
- aece1df ast: Visit `Program`s `hashbang` field first (#4368 )
(overlookmotel)
- 44a10c4 codegen: Object shorthand with parens `({x: (x)})` -> `({ x
})` (#4391 ) (Boshen)
- 3d88f20 codegen: Print shorthand for all `{ x }` variants (#4374 )
(Boshen)
- e624dff codegen,mangler: Do not print shorthand for `ObjectProperty`
(#4350 ) (Boshen)
- ac08de8 linter/react_perf: Allow new objects, array, fns, etc in top
scope (#4395 ) (DonIsaac)
- 267f7c4 minifier: Skip `Object.defineProperty(exports, ...)` for
`cjs-module-lexer` (#4409 ) (Boshen)
- bc8d4e5 semantic: Correct comment (#4410 ) (overlookmotel)
- 6ffce86 semantic: Align `visit_arrow_function_expression` field visit
order with ast (#4366 ) (Dunqing)
- 4cd5df0 sourcemap: Avoid negative line if token_chunks has same
prev_dst_line (#4348 ) (underfin)
- f8565ae transformer/typescript: Unexpectedly removed class binding
from ExportNamedDeclaration (#4351 ) (Dunqing)- ea33f94 Impl
PartialEq<str> for CompactStr (#4352 ) (DonIsaac)
### Performance
- 1b51511 semantic: Use `Atom` instead of `CompactStr` for
`UnresolvedReferencesStack` (#4401 ) (Dunqing)
- 40f9356 semantic: Calculate number of nodes, scopes, symbols,
references before visiting AST (#4367 ) (Dunqing)
- da13d93 semantic: Remove bounds checks on unresolved references stack
(#4390 ) (overlookmotel)
- e70c67b semantic: Remove a branch from `add_scope` (#4384 )
(overlookmotel)
- 402006f semantic: Simplify logic in `enter_scope` + `leave_scope`
(#4383 ) (overlookmotel)
- 7469e01 semantic: Remove branch from `Nodes::add_node` (#4361 )
(overlookmotel)
- 7eb2864 traverse: Speed up finding UID binding name (#4356 )
(overlookmotel)- a207923 Replace some CompactStr usages with Cows
(#4377 ) (DonIsaac)
### Refactor
- d213773 ast: Replace serde rename "lowercase" with "camelCase" (#4376 )
(overlookmotel)
- abfccbd ast: Reduce `#[cfg_attr]` boilerplate in AST type defs (#4375 )
(overlookmotel)
- 5f1c7ec ast: Rename the `visited_node` marker to `ast`. (#4289 )
(rzvxa)
- 58f6ec2 ast: Enter node before scope (#4347 ) (Dunqing)
- 59aea73 ast: Scope is created only if CatchClause has param (#4346 )
(Dunqing)
- 7a3e925 ast_codegen: Better visit marker parsing. (#4371 ) (rzvxa)
- 7a75e0f linter: Use diagnostic codes in lint rules (#4349 ) (DonIsaac)
- a2eabe1 parser: Use error codes for ts diagnostics (#4335 ) (DonIsaac)
- 5d77b36 semantic: `visit_program` visit `hashbang` field (#4370 )
(overlookmotel)
- f7b9ada semantic: `Program` visitor leave scope before node (#4369 )
(overlookmotel)
- 729b288 semantic: Shorten code (#4358 ) (overlookmotel)
- 21d0eee semantic: Use error codes for ts diagnostics (#4336 )
(DonIsaac)
Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-07-23 13:24:08 +08:00
IWANABETHATGUY
01f33cfe1c
chore: fix failed publish caused by cyclic dev dependencies ( #4416 )
...
1. This looks like caused by
https://github.com/rust-lang/cargo/issues/4242
## Ref
1. https://github.com/rust-lang/futures-rs/pull/2305
2024-07-23 13:10:53 +08:00