Commit graph

7528 commits

Author SHA1 Message Date
Dunqing
8ed976661a
fix(codegen): source map builder panicked because it attempted to subtract with overflow in search_original_line_and_column (#8185)
See:
https://github.com/oxc-project/monitor-oxc/actions/runs/12531534720/job/34949348092
Related: #7926 

This line causes panic.

46fc1a8b7d/crates/oxc_codegen/src/sourcemap_builder.rs (L147-L148)

After investigation, I found that the root cause was the code removed
in this PR. I don’t understand what the code was used for, but it was
obviously wrong. Because `idx` is always smaller than `cap`
2024-12-31 20:00:41 +08:00
Boshen
56b7f133fa fix(minifier): do not constant fold 0 instanceof F (#8199) 2024-12-31 08:46:57 +00:00
Cameron
bf266e13b0
feat(minifier): try collapse conditional to logical or expr (#8197) 2024-12-31 15:59:08 +08:00
Dunqing
3eaff2a51c fix(transformer): ensure last expression statement in arrow function expression is wrapped in return (#8192)
The class properties plugin will insert new statements after the expression statement, which causes the expression statement to no longer be at the end. This PR fixed it by reverse looping the statements to find the expression statement and transforming it to wrapped in `return`.

This is not a good way to do it, a potential problem is if there is a plugin that inserts a new expression statement after the original expression statement, which will cause a wrong expression wrapped in a `return`
2024-12-31 01:29:53 +00:00
Boshen
06e1780b8c feat(minifier): improve StatementFusion (#8194) 2024-12-31 01:13:24 +00:00
Boshen
42e211ad6b feat(minifier): only constant fold numbers when result is smaller (#8092) 2024-12-31 00:56:51 +00:00
Alexander S.
bde44a3720
feat(linter): add statement_span to ModuleRecord/ImportEntry (#8195)
Probably a breaking change. 

this is needed for the diagnostic in `no-restricted-imports`:
https://github.com/oxc-project/oxc/pull/8113

you can see the eslint expection here:

https://github.com/eslint/eslint/blob/main/tests/lib/rules/no-restricted-imports.js#L487-L517

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-31 08:47:26 +08:00
branchseer
f88acb331b
fix(parser): allow line breaks between const and enum (#8193)
https://www.typescriptlang.org/play/?ts=5.7.2#code/MYewdgzgLgUApmArgWwAQEFUG8C+Mg
2024-12-31 08:45:17 +08:00
Alexander S.
ccaa9f71e1
feat(linter): implement eslint/new-cap (#8146)
https://eslint.org/docs/latest/rules/new-cap

Same Problem with rust regex instead of js regex. Added a note in the
docs
2024-12-30 13:43:50 +00:00
Boshen
d0de560f6d feat(minifier): change NaN to f64::NAN (#8191) 2024-12-30 08:49:55 +00:00
翠 / green
cef8eb8077
feat(minifier): change foo?.['bar'] to foo?.bar (#8176)
ChainExpression's `expression` field is `ChainElement` and not
`Expression` so the previous code did not run for optional chainings.
2024-12-30 16:47:56 +08:00
oxc-bot
936623ea45
release(oxlint): v0.15.4 (#8190)
## [0.15.4] - 2024-12-30

### Features

- 47cea9a linter: Implement `eslint/no-extra-label` (#8181) (Anson
Heung)
- ef76e28 linter: Implement `eslint/no-multi-assign` (#8158) (Anson
Heung)
- 384858b linter: Implement `jsx-a11y/no-noninteractive-tabindex`
(#8167) (Tyler Earls)
- afc21a6 linter: Implement `eslint/vars-on-top` (#8157) (Yuichiro
Yamashita)
- 65796c4 linter: Implement `eslint/prefer-rest-params` (#8155)
(Yuichiro Yamashita)
- 5234d96 linter: Implement `eslint/no-nested-ternary` (#8150) (Yuichiro
Yamashita)
- 1c5db72 linter: Implement eslint/no-labels (#8131) (Anson Heung)
- 0b04288 linter: Move `import/named` to nursery (#8068) (Boshen)

### Bug Fixes

- 0794bee editor/vscode: Set minimum supported ver. to `^1.93.0` (#8182)
(Pavel Smirnov)
- f3050d4 linter: Exclude svelte files from `no_unused_vars` rule
(#8170) (Yuichiro Yamashita)
- faf7464 linter: Disable rule `react/rules-of-hook` by file extension
(#8168) (Alexander S.)
- 1171e00 linter: Disable `react/rules-of-hooks` for vue and svelte
files (#8165) (Alexander S.)
- 1b9a5ba linter: False positiver in private member expr in
oxc/const-comparison (#8164) (camc314)
- 6bd9ddb linter: False positive in `typescript/ban-tslint-comment`
(#8094) (dalaoshu)
- 10a1fd5 linter: Rule: `no-restricted-imports` support option
`patterns` with `group` key (#8050) (Alexander S.)
- b3f38ae linter: Rule `no-restricted-imports`: support option
`allowImportNames` (#8002) (Alexander S.)
- 340cc90 linter: Rule `no-restricted-imports`: fix option "importNames"
(#7943) (Alexander S.)
- ec2128e linter: Fix line calculation for `eslint/max-lines` in
diagnostics (#7962) (Dmitry Zakharov)
- 79af100 semantic: Reference flags not correctly resolved when after an
export stmt (#8134) (camc314)

### Performance

- d8d2ec6 linter: Run rules which require typescript syntax only when
source type is actually typescript (#8166) (Alexander S.)
- 2736657 semantic: Allocate `UnresolvedReferences` in allocator (#8046)
(Boshen)

### Refactor

- de8246b language_server: Move structs into own file (#8026) (Alexander
S.)
- 774babb linter: Read `exported_bindings_from_star_export` lazily
(#8062) (Boshen)
- 547c102 linter: Use `RwLock<FxHashMap>` instead of `FxDashMap` for
module record data (#8061) (Boshen)
- 952d7e4 linter: Rename `flat.rs` to `config.rs` (#8033) (camc314)
- 50848ed linter: Simplify `ConfigStore` to prep for nested configs
(#8032) (camc314)
- b2a4a78 linter: Remove unused `with_rules` and `set_rule` methods
(#8029) (camc314)
- 6da0b21 oxlint: Remove unused `git.rs` (#7990) (Boshen)
- 58e7777 oxlint: Remove extra if check in `Walkdir` (#7989) (Boshen)
- 02f968d semantic: Change `Bindings` to a plain `FxHashMap` (#8019)
(Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-30 15:47:06 +08:00
Max Stoumen
55744fd977
feat(semantic): allow getting mutable reference to symbols table (#8189)
Seems like the only way to get a mutable reference to the `SymbolTable`
inside `Semantic` right now is with `into_symbol_table_and_scope_tree`,
but that drops other useful info.

Since `scopes_mut` exists I figure this would be reasonable too?

Reason I'm requesting this is I have a project where I need to fill in
some symbols `oxc_semantic` doesn't yet pick up on (like function
overloads, `declare`'d symbols) and this would be the cleanest way to do
it.
2024-12-30 15:27:30 +08:00
renovate[bot]
11e598ecb1
chore(deps): update rust crates (#8186)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [console](https://redirect.github.com/console-rs/console) |
workspace.dependencies | patch | `0.15.8` -> `0.15.10` |
| [env_logger](https://redirect.github.com/rust-cli/env_logger) |
workspace.dependencies | patch | `0.11.5` -> `0.11.6` |
| [fast-glob](https://redirect.github.com/shulaoda/fast-glob) |
workspace.dependencies | patch | `0.4.0` -> `0.4.3` |
| [glob](https://redirect.github.com/rust-lang/glob) |
workspace.dependencies | patch | `0.3.1` -> `0.3.2` |
|
[oxc-browserslist](https://redirect.github.com/oxc-project/oxc-browserslist)
| workspace.dependencies | patch | `1.1.0` -> `1.1.1` |
| [oxc_resolver](https://redirect.github.com/oxc-project/oxc-resolver) |
workspace.dependencies | patch | `3.0.1` -> `3.0.3` |
| [oxc_sourcemap](https://redirect.github.com/oxc-project/oxc-sourcemap)
| workspace.dependencies | patch | `1.0.5` -> `1.0.6` |
| [quote](https://redirect.github.com/dtolnay/quote) |
workspace.dependencies | patch | `1.0.37` -> `1.0.38` |
| [serde](https://serde.rs)
([source](https://redirect.github.com/serde-rs/serde)) |
workspace.dependencies | patch | `1.0.216` -> `1.0.217` |
| [serde_json](https://redirect.github.com/serde-rs/json) |
workspace.dependencies | patch | `1.0.133` -> `1.0.134` |
| [syn](https://redirect.github.com/dtolnay/syn) |
workspace.dependencies | patch | `2.0.90` -> `2.0.93` |

---

### Release Notes

<details>
<summary>console-rs/console (console)</summary>

###
[`v0.15.10`](https://redirect.github.com/console-rs/console/releases/tag/0.15.10)

[Compare
Source](https://redirect.github.com/console-rs/console/compare/0.15.9...0.15.10)

#### What's Changed

- Remove MSRV badge from README by
[@&#8203;djc](https://redirect.github.com/djc) in
[https://github.com/console-rs/console/pull/228](https://redirect.github.com/console-rs/console/pull/228)

###
[`v0.15.9`](https://redirect.github.com/console-rs/console/releases/tag/0.15.9)

[Compare
Source](https://redirect.github.com/console-rs/console/compare/0.15.8...0.15.9)

#### What's Changed

- Update dependencies by [@&#8203;djc](https://redirect.github.com/djc)
in
[https://github.com/console-rs/console/pull/227](https://redirect.github.com/console-rs/console/pull/227)

</details>

<details>
<summary>rust-cli/env_logger (env_logger)</summary>

###
[`v0.11.6`](https://redirect.github.com/rust-cli/env_logger/blob/HEAD/CHANGELOG.md#0116---2024-12-20)

[Compare
Source](https://redirect.github.com/rust-cli/env_logger/compare/v0.11.5...v0.11.6)

##### Features

-   Opt-in file and line rendering

</details>

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

###
[`v0.3.2`](https://redirect.github.com/rust-lang/glob/blob/HEAD/CHANGELOG.md#032---2024-12-28)

[Compare
Source](https://redirect.github.com/rust-lang/glob/compare/0.3.1...v0.3.2)

</details>

<details>
<summary>oxc-project/oxc-browserslist (oxc-browserslist)</summary>

###
[`v1.1.1`](https://redirect.github.com/oxc-project/oxc-browserslist/blob/HEAD/CHANGELOG.md#111---2024-12-14)

[Compare
Source](https://redirect.github.com/oxc-project/oxc-browserslist/compare/oxc-browserslist-v1.1.0...oxc-browserslist-v1.1.1)

##### Other

-   codegen
-   dprint
-   Update README.md
-   *(deps)* update rust crates
-   *(deps)* update rust crates
- *(deps)* update dependency rust to v1.83.0
([#&#8203;78](https://redirect.github.com/oxc-project/oxc-browserslist/issues/78))
-   *(deps)* update rust crates
-   *(deps)* update rust crates to v1.0.215
-   *(deps)* update rust crate thiserror to v2.0.3
-   *(deps)* update rust crate thiserror to v2
-   *(deps)* update rust crates to v1.0.93
-   `cargo autoinherit`
-   *(deps)* update rust crate criterion2 to v2

</details>

<details>
<summary>oxc-project/oxc-resolver (oxc_resolver)</summary>

###
[`v3.0.3`](https://redirect.github.com/oxc-project/oxc-resolver/blob/HEAD/CHANGELOG.md#303---2024-12-14)

[Compare
Source](https://redirect.github.com/oxc-project/oxc-resolver/compare/oxc_resolver-v3.0.2...oxc_resolver-v3.0.3)

##### <!-- 1 -->Bug Fixes

- try browsers field and alias before resolving directory in
node_modules
([#&#8203;349](https://redirect.github.com/oxc-project/oxc-resolver/issues/349))

###
[`v3.0.2`](https://redirect.github.com/oxc-project/oxc-resolver/blob/HEAD/CHANGELOG.md#302---2024-12-13)

[Compare
Source](https://redirect.github.com/oxc-project/oxc-resolver/compare/oxc_resolver-v3.0.1...oxc_resolver-v3.0.2)

##### <!-- 1 -->Bug Fixes

- special case for aliasing `@/`
([#&#8203;348](https://redirect.github.com/oxc-project/oxc-resolver/issues/348))
- normalize resolved result on Windows for root
([#&#8203;345](https://redirect.github.com/oxc-project/oxc-resolver/issues/345))

##### <!-- 4 -->Refactor

- replace UnsafeCell with RefCell
([#&#8203;346](https://redirect.github.com/oxc-project/oxc-resolver/issues/346))

</details>

<details>
<summary>oxc-project/oxc-sourcemap (oxc_sourcemap)</summary>

###
[`v1.0.6`](https://redirect.github.com/oxc-project/oxc-sourcemap/blob/HEAD/CHANGELOG.md#106---2024-12-15)

[Compare
Source](https://redirect.github.com/oxc-project/oxc-sourcemap/compare/v1.0.5...v1.0.6)

##### Fixed

- handle non existing token position in visualizer
([#&#8203;14](https://redirect.github.com/oxc-project/oxc-sourcemap/issues/14))

</details>

<details>
<summary>dtolnay/quote (quote)</summary>

###
[`v1.0.38`](https://redirect.github.com/dtolnay/quote/releases/tag/1.0.38)

[Compare
Source](https://redirect.github.com/dtolnay/quote/compare/1.0.37...1.0.38)

- Support interpolating arrays inside of arrays using a repetition
([#&#8203;286](https://redirect.github.com/dtolnay/quote/issues/286))

</details>

<details>
<summary>serde-rs/serde (serde)</summary>

###
[`v1.0.217`](https://redirect.github.com/serde-rs/serde/releases/tag/v1.0.217)

[Compare
Source](https://redirect.github.com/serde-rs/serde/compare/v1.0.216...v1.0.217)

- Support serializing externally tagged unit variant inside flattened
field
([#&#8203;2786](https://redirect.github.com/serde-rs/serde/issues/2786),
thanks [@&#8203;Mingun](https://redirect.github.com/Mingun))

</details>

<details>
<summary>serde-rs/json (serde_json)</summary>

###
[`v1.0.134`](https://redirect.github.com/serde-rs/json/releases/tag/v1.0.134)

[Compare
Source](https://redirect.github.com/serde-rs/json/compare/v1.0.133...v1.0.134)

- Add `RawValue` associated constants for literal `null`, `true`,
`false`
([#&#8203;1221](https://redirect.github.com/serde-rs/json/issues/1221),
thanks [@&#8203;bheylin](https://redirect.github.com/bheylin))

</details>

<details>
<summary>dtolnay/syn (syn)</summary>

###
[`v2.0.93`](https://redirect.github.com/dtolnay/syn/releases/tag/2.0.93)

[Compare
Source](https://redirect.github.com/dtolnay/syn/compare/2.0.92...2.0.93)

- Fix expression parsing edge cases: `x as T <<= y`
([#&#8203;1804](https://redirect.github.com/dtolnay/syn/issues/1804)),
`break as T`
([#&#8203;1805](https://redirect.github.com/dtolnay/syn/issues/1805)),
`match x { _ if .. => {} }`
([#&#8203;1807](https://redirect.github.com/dtolnay/syn/issues/1807))
- Fix expression printing edge cases: `|| -> T 'a: {}`
([#&#8203;1806](https://redirect.github.com/dtolnay/syn/issues/1806)),
`if break x {}`
([#&#8203;1808](https://redirect.github.com/dtolnay/syn/issues/1808),
[#&#8203;1810](https://redirect.github.com/dtolnay/syn/issues/1810))

###
[`v2.0.92`](https://redirect.github.com/dtolnay/syn/releases/tag/2.0.92)

[Compare
Source](https://redirect.github.com/dtolnay/syn/compare/2.0.91...2.0.92)

- Fix parenthesization of jumps inside ranges
([#&#8203;1798](https://redirect.github.com/dtolnay/syn/issues/1798))

###
[`v2.0.91`](https://redirect.github.com/dtolnay/syn/releases/tag/2.0.91)

[Compare
Source](https://redirect.github.com/dtolnay/syn/compare/2.0.90...2.0.91)

- Support parsing `Vec<Arm>` using `parse_quote!`
([#&#8203;1796](https://redirect.github.com/dtolnay/syn/issues/1796),
[#&#8203;1797](https://redirect.github.com/dtolnay/syn/issues/1797))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 11am on monday" in timezone
Asia/Shanghai, Automerge - "before 11am on monday" in timezone
Asia/Shanghai.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config
help](https://redirect.github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiIzOS44NS4wIiwidXBkYXRlZEluVmVyIjoiMzkuODUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2024-12-30 15:25:17 +08:00
Pavel Smirnov
0794bee907
fix(editor/vscode): set minimum supported ver. to ^1.93.0 (#8182)
Hi,

I'm using Cursor which is based on VSCode `1.93` at the moment of this
PR. And i've faced with an issue when i can't install latest version of
oxc vscode plugin - by default plugin marketplace offers me `v0.0.1` and
via `Install Specific Version` i can install only `v0.10.3` while latest
is `v0.15.3`. No idea when Cursor will update its version.
There's no issue with VSCode, only Cursor.

After downgrading minimum version, Cursor allowed me to install plugin
that i compiled by myself, everything seem to be working.

Not sure about how is usually contributions made here so correct me if i
miss something
2024-12-30 15:22:54 +08:00
Anson Heung
47cea9a52d
feat(linter): implement eslint/no-extra-label (#8181)
Implements
[eslint/no-extra-label](https://eslint.org/docs/latest/rules/no-extra-label).

---------

Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2024-12-29 18:16:24 +00:00
Anson Heung
ef76e288ca
feat(linter): implement eslint/no-multi-assign (#8158)
Implements [eslint/no-multi-assign](https://eslint.org/docs/latest/rules/no-multi-assign)
rule.
2024-12-29 17:15:12 +00:00
Tyler Earls
384858b9ed
feat(linter): implement jsx-a11y/no-noninteractive-tabindex (#8167)
This PR implements the
[jsx-a11y/no-noninteractive-tabindex](91e39b45ad/docs/rules/no-noninteractive-tabindex.md)
rule.

I set the default values as the ones that are in the recommended config.

I used this [html spec
section](https://html.spec.whatwg.org/multipage/dom.html#interactive-content)
to source the interactive elements.

The interactive roles came from [this article in the MDN
docs](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#2._widget_roles).
2024-12-29 17:14:37 +00:00
Yuichiro Yamashita
afc21a6071
feat(linter): implement eslint/vars-on-top (#8157)
implement: https://eslint.org/docs/latest/rules/vars-on-top
2024-12-29 17:13:45 +00:00
Yuichiro Yamashita
a2adc4e832
chore(linter): move no-negated-condition to eslint (#8149)
Moves `unicorn/no-negated-condition` to `eslint/no-negated-condition`

Maps `unicorn/no-negated-condition`to `eslint/no-negated-condition`

docs: https://eslint.org/docs/latest/rules/no-negated-condition
2024-12-29 17:12:51 +00:00
Yuichiro Yamashita
f3050d4f31
fix(linter): exclude svelte files from no_unused_vars rule (#8170) 2024-12-29 17:10:33 +00:00
Boshen
cfb51f2551 refactor(minifier): fuse ast passes (#8184) 2024-12-29 14:57:20 +00:00
Boshen
bf9cafea90
refactor(minifier): clean up peephole_substitute_alternate_syntax a little bit 2024-12-29 20:50:53 +08:00
Boshen
8149e34bf0 feat(minifier): optional catch binding when es target >= es2019 (#8180) 2024-12-29 12:27:33 +00:00
Boshen
41ddf60ab0 feat(minfier): add CompressOptions::target (#8179) 2024-12-29 12:27:32 +00:00
Boshen
ad146bbb90 feat(codegen): print real newline when \n is inside template literals (#8178) 2024-12-29 12:20:47 +00:00
sapphi-red
75d5f17dbd
fix(minifier): minify string PropertyKey (#8177)
#8169 added `if self.in_fixed_loop` in `try_compress_property_key`. Because `exit_property_key` was not called for `PeepholeOptimizations`, `try_compress_property_key` was never called.

refs #8147
2024-12-29 07:49:42 +00:00
sapphi-red
1fa53413e0
test(minifier): port tests from ConvertToDottedPropertiesTest (#8175) 2024-12-29 07:19:13 +00:00
sapphi-red
fc43ec530e
feat(minifier): fold string.length / array.length (#8172) 2024-12-29 07:14:13 +00:00
Boshen
29dc0dc070 feat(minifier): change foo['bar'] -> foo.bar (#8169) 2024-12-29 04:09:42 +00:00
翠 / green
3c5718d68b
feat(minifier): fold typeof foo == undefined into foo == undefined when possible (#8160) 2024-12-29 11:49:57 +08:00
Alexander S.
faf7464733
fix(linter): disable rule react/rules-of-hook by file extension (#8168) 2024-12-28 18:52:10 +00:00
Alexander S.
d8d2ec6257
perf(linter): run rules which require typescript syntax only when source type is actually typescript (#8166) 2024-12-28 17:03:11 +00:00
翠 / green
9d62284202
chore(tasks): print diff for minify idempotency assertion (#8161)
Made the assertion error output more easier to understand.

Example output:

![image](https://github.com/user-attachments/assets/445910fb-b389-4884-b4c5-70a095bc523f)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-29 00:55:45 +08:00
翠 / green
f3a36e1dbf
feat(minifier): fold typeof foo != "undefined" into typeof foo < "u" (#8159) 2024-12-29 00:50:56 +08:00
Yuichiro Yamashita
65796c47a1
feat(linter): implement eslint/prefer-rest-params (#8155)
implement: https://eslint.org/docs/latest/rules/prefer-rest-params
2024-12-28 16:42:01 +00:00
Alexander S.
1171e00a3c
fix(linter): disable react/rules-of-hooks for vue and svelte files (#8165)
because of https://github.com/oxc-project/oxc/issues/8003

I used the FrameworkFlags in hope they are only active in `.vue` and
`.svelte` files.
2024-12-28 16:34:58 +00:00
camc314
1b9a5bae2e fix(linter): false positiver in private member expr in oxc/const-comparison (#8164)
fixes https://github.com/oxc-project/oxc/issues/8163
2024-12-28 13:49:10 +00:00
Boshen
37c9959611 feat(minifier): normalize Infinity into f64::Infinity (#8148) 2024-12-28 06:05:04 +00:00
Yuichiro Yamashita
5234d964fb
feat(linter): implement eslint/no-nested-ternary (#8150)
implement: https://eslint.org/docs/latest/rules/no-nested-ternary

---------

Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2024-12-27 23:44:44 +00:00
Anson Heung
1c5db72986
feat(linter): implement eslint/no-labels (#8131)
Implements [eslint/no-labels](https://eslint.org/docs/latest/rules/no-labels) rule.

Part of #479
2024-12-27 15:30:14 +00:00
Boshen
8fb71f518f feat(minifier): minify string PropertyKey (#8147) 2024-12-27 15:09:41 +00:00
camc314
79af10070d fix(semantic): reference flags not correctly resolved when after an export stmt (#8134)
fixes https://github.com/oxc-project/oxc/issues/7879#issuecomment-2562574889

TLDR is curently here:

cdd121bfa4/crates/oxc_semantic/src/builder.rs (L2130-L2135)

`self.current_reference_flags.is_empty()` is not empty, which causes the current ref flags to be used (this is incorrect, we should be using a fresh version of reference flags). Buy setting ref flags to `None` on exit export node, this issue is avoided

`export` **BEFORE** the reference ( incorrect reference flags)

https://playground.oxc.rs/#eNpVjjuOwzAMRK8isElj7A/YxtttkVOkkR3aECCJBskkdgzdPZISG0ilGc3DcFbooQUXJmI1q/m3bJIZmII5fHx2lg9/p4hzTXWZsCL3N+RekB3qvRUxRyKDs2I8S61cEzRA0K7Al1geWaLaGVrlCzbgXdRNS08T7mYJHfnNKdsoA3GAdrBeMDUwWRbk3Jh1adn0jtYPUMsj5hOA8vP1/QuZ6OmMI5Yx2QQX3eCebLBx9K8FlYvK5I+ebiW9InckOX4uSOkBCrdvkw==

`export` **AFTER** the reference ( correct reference flags)

https://playground.oxc.rs/#eNpVjj2uwjAQhK9ibZMmen/Sa0JHwSlonLCJLNm70a6BhMh3xzEEQeUZz6fZWaCDBlwYWaJZzN6KSaYXDqb6+m6tVLsjHQmnknfeqpoDs8EpIp208Et6Q+I8Yum5ffTcqh3UwNAsIGdaH50p2gmaKGeswTuKm9aOR3yZObTsNxfFkvYsAZreesVUw2hFUXJj1mvLpl9o+YBoZcB8AlD/fn7/IRMdn3DAdUw2wZHr3YMNlgb/XFA4isL+4Pm6pheUljXHjwUp3QEtmnBd

this PR fixes this issue by resetting the reference flags after exising an export stmt
2024-12-27 14:20:17 +00:00
翠 / green
74572de625
fix(ecmascript): incorrect to_int_32 value for Infinity (#8144)
https://tc39.es/ecma262/#sec-toint32
Infinity should return `0` when passed to `ToInt32` abstract operation.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-27 21:48:25 +08:00
翠 / green
6615e1ea93
feat(minifier): constant fold instanceof (#8142) 2024-12-27 21:45:31 +08:00
Boshen
75264ed7d6 refactor(minifier): clean up try_optimize_block (#8139) 2024-12-27 06:46:21 +00:00
Boshen
2b2a37347c feat(minifier): minimize a + 'b' + 'c' -> a + 'bc' (#8137) 2024-12-27 05:46:51 +00:00
Boshen
213364a400 feat(minifier): minimize if (x) if (y) z -> if (x && y) z (#8136) 2024-12-27 02:44:47 +00:00
Boshen
ad61e70186 fix(codegen): print if else without block with proper indentation (#8135) 2024-12-27 00:39:52 +00:00
Boshen
6b51e6dff1 feat(minifier): minimize if(foo) bar else baz -> foo ? bar : baz (#8133) 2024-12-26 16:21:34 +00:00