Commit graph

673 commits

Author SHA1 Message Date
Boshen
ed6a69e2db
chore(coverage): update runtime.snap 2024-11-25 22:36:05 +08:00
Boshen
6f161de10f chore(coverage): bump test262, babel and TypeScript submodules (#7452) 2024-11-24 16:26:45 +00:00
Dunqing
4d6bd07afe fix(transformer/async-generator-functions): correct all binding scope id (#7425)
Fixed a bunch of semantic errors by removing moving binding logic 😢. This plugin constructs a complex `for-await` replacement so that I wrongly move to an incorrect scope.
2024-11-22 16:29:00 +00:00
Dunqing
27b2268a6c refactor(semantic)!: remove SymbolFlags::Export (#7414)
close: #7338
close: #7344

The `SymbolFlags::Export` is Initially used to solve `ExportSpecifier` that is not `IdentifierReference` that causes we cannot determine whether a Binding is not used everywhere by `Semantic`.

Since #3820 this problem is solved, so we don't need `SymbolFlags::Export` no longer. Also, removing this can help us easier to pass the `Semantic` check in `Transformer`
2024-11-22 09:17:37 +00:00
Dunqing
7ff9f13973 fix(transformer): correct all ReferenceFlags (#7410) 2024-11-22 09:10:55 +00:00
Dunqing
6f0fe38bff fix(semantic)!: correct all ReferenceFlags::Write according to the spec (#7388)
close #7323

According to the specification re-design the JavaScript-part ReferenceFlags inferring approach.

* https://tc39.es/ecma262/#sec-assignment-operators-runtime-semantics-evaluation
* https://tc39.es/ecma262/#sec-postfix-increment-operator-runtime-semantics-evaluation
* https://tc39.es/ecma262/#sec-runtime-semantics-restdestructuringassignmentevaluation
* ... See references of https://tc39.es/ecma262/#sec-putvalue

### Changes

1. The left-hand of `AssignmentExpression` is always `ReferenceFlags::Write`
```js
let a = 0;
console.log(a = 0);
            ^ Write only
```

2. The `argument` of `UpdateExpression` is always `ReferenceFlags::Read | Write`
```js
let a = 0;
a++;
^ Read and Write
```

This change might cause some trouble for `Minfier` to remove this code, because ‘a’ is not used elsewhere. I have taken a look at `esbuild` and `Terser`. Only the `Terser` can remove this code.
2024-11-22 06:08:30 +00:00
Boshen
224775c056 feat(transformer): transform object rest spread (#7003)
https://babel.dev/docs/babel-plugin-transform-object-rest-spread
2024-11-21 11:33:26 +00:00
Boshen
885e37f8eb feat(transformer): Optional Chaining (#6990)
close: #6958
2024-11-21 03:12:18 +00:00
Boshen
0c1fb96760 fix(tasks/coverage): run runtime tasks concurrently to avoid timeout (#7384) 2024-11-21 03:05:20 +00:00
Dunqing
6cfb5df9b9 feat(transformer): support generate proper binding name from ChainExpression (#7326) 2024-11-19 10:31:54 +00:00
Boshen
7b83a3ddfa
chore(tasks/coverage): update runtime.snap 2024-11-18 18:01:49 +08:00
Song Gao
cf3415b0e4
chore(doc): replace main/master to tag/commit to make the url always accessible (#7298) 2024-11-16 21:00:30 +08:00
7086cmd
cf99be0a0d fix(minifier): do not compare bigint with object (#7294)
@Boshen, could you please update the snap of runtime and commit to this PR? I want to see the effects after the unit tests are added.
2024-11-16 06:01:06 +00:00
Boshen
8d8f34cfb5
chore(tasks/coverage): update runtime.snap 2024-11-15 12:48:56 +08:00
Dunqing
eea4ab830a fix(transformer/helper-loader): incorrect SymbolFlags for default import when SourceType is script (#7226) 2024-11-09 14:32:44 +00:00
Boshen
b4258ee58e feat(transformer): add defaulted Module::Preserve option (#7225) 2024-11-09 12:55:13 +00:00
Dunqing
5cfdc05d06 feat(transformer/typescript): support transform export = and import = require(...) when module is commonjs (#7206)
close: #7141
2024-11-09 09:32:28 +00:00
Boshen
b11ed2cf7b refactor(ast)!: remove useless ObjectProperty::init field (#7220)
closes https://github.com/oxc-project/backlog/issues/143
2024-11-09 09:00:29 +00:00
Boshen
0e4adc15dd feat(ast)!: remove invalid expressions from TSEnumMemberName (#7219) 2024-11-09 08:48:14 +00:00
Boshen
846711cf41 feat(transformer)!: change API to take a &TransformOptions instead of TransformOptions (#7213)
closes #7185

`TransformOption`s has an initialization cost, it should be initialized once and shared across files.
2024-11-09 06:01:13 +00:00
Dunqing
ede10dc030 fix(transformer/async-to-generator): incorrect transform when super expression is inside async method (#7171)
After transformation, super expressions have moved to unexpected places. This PR replaces super expression to call expression, and then inserts the super methods to the top of the method body.

For example:

Before:
```js
class G {
  async method() {
    super.foo()
  }
}
```

After:
```js
class G {
  method() {
    var _superprop_getFoo = () => super.foo,
      _this = this;
    return _asyncToGenerator(function* () {
      _superprop_getFoo().call(_this);
    })();
  }
}```
2024-11-08 08:18:45 +00:00
Dunqing
1910227590 feat(transformer/async-to-generator): support inferring the function name from the ObjectPropertyValue's key (#7201)
Support for inferring function name from ObjectPropertyValue's key

For example:
```js
({ foo: async function() {} })
```

After this, we will able to infer `foo` for the object method
2024-11-08 08:18:44 +00:00
Dunqing
293d072e77 fix(transformer/async-to-generator): only transform object method in exit_function (#7199)
part of #7175
2024-11-08 03:03:27 +00:00
Huáng Jùnliàng
9a6423a9f8
test(coverage): enable Babel es2022 tests (#7194)
Enabled the Babel es2022 tests. Previously they were skipped probably
because ES2022 was not yet supported at that time.
2024-11-08 09:29:36 +08:00
Dunqing
8573f79c6d feat(transformer): turn on async_to_generator and async_generator_functions plugins in enable_all (#7135) 2024-11-06 03:27:13 +00:00
Boshen
52c20d633c refactor(transformer): deserialize BabelOptions::plugins (#7045) 2024-11-01 05:44:57 +00:00
Boshen
4bef99c80b
chore(coverage): update runtime snapshot 2024-11-01 13:05:42 +08:00
tomoya yanagibashi
0601271b2c
fix(ast): Fix StaticMemberExpression.get_first_object (#6969)
I think `get_first_object` does not return expected expression.

For example, in case of `foo.bar.a`, it doesn't return `foo` but
`foo.bar`.

**Expected**
```
{
  "type": "Identifier",
  "start": 0,
  "end": 3,
  "name": "foo"
}
```

**Actual**
```
{
   "type":"StaticMemberExpression",
   "start":0,
   "end":7,
   "object":{
      "type":"Identifier",
      "start":0,
      "end":3,
      "name":"foo"
   },
   "property":{
      "type":"Identifier",
      "start":4,
      "end":7,
      "name":"bar"
   },
   "optional":false
}
```

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-11-01 12:28:48 +08:00
Boshen
fcaba4a92a feat(transformer): add TransformerOptions::env with EnvOptions (#7037) 2024-10-31 12:30:32 +00:00
Boshen
caaf00e081 fix(parser): fix incorrect parsed TSIndexSignature (#7016)
closes #6985
2024-10-30 07:34:22 +00:00
Boshen
b518670582
chore(coverage): remove known runtime issues 2024-10-28 21:38:37 +08:00
renovate
56f5506ca9 chore(deps): update rust crates (#6961)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [encoding_rs](https://docs.rs/encoding_rs/) ([source](https://redirect.github.com/hsivonen/encoding_rs)) | workspace.dependencies | patch | `0.8.34` -> `0.8.35` |
| [handlebars](https://redirect.github.com/sunng87/handlebars-rust) | workspace.dependencies | minor | `6.1.0` -> `6.2.0` |
| [insta](https://insta.rs/) ([source](https://redirect.github.com/mitsuhiko/insta)) | workspace.dependencies | minor | `1.40.0` -> `1.41.0` |
| [prettyplease](https://redirect.github.com/dtolnay/prettyplease) | workspace.dependencies | patch | `0.2.24` -> `0.2.25` |
| [regex](https://redirect.github.com/rust-lang/regex) | workspace.dependencies | patch | `1.11.0` -> `1.11.1` |
| [saphyr](https://redirect.github.com/saphyr-rs/saphyr) | workspace.dependencies | patch | `0.0.1` -> `0.0.3` |
| [serde](https://serde.rs) ([source](https://redirect.github.com/serde-rs/serde)) | workspace.dependencies | patch | `1.0.210` -> `1.0.213` |
| [tokio](https://tokio.rs) ([source](https://redirect.github.com/tokio-rs/tokio)) | workspace.dependencies | minor | `1.40.0` -> `1.41.0` |

---

### Release Notes

<details>
<summary>hsivonen/encoding_rs (encoding_rs)</summary>

### [`v0.8.35`](https://redirect.github.com/hsivonen/encoding_rs/compare/v0.8.34...v0.8.35)

[Compare Source](https://redirect.github.com/hsivonen/encoding_rs/compare/v0.8.34...v0.8.35)

</details>

<details>
<summary>sunng87/handlebars-rust (handlebars)</summary>

### [`v6.2.0`](https://redirect.github.com/sunng87/handlebars-rust/blob/HEAD/CHANGELOG.md#620---2024-10-26)

[Compare Source](https://redirect.github.com/sunng87/handlebars-rust/compare/v6.1.0...v6.2.0)

-   \[Added] `@index` variable for object iteration \[[#&#8203;682](https://redirect.github.com/sunng87/handlebars-rust/issues/682)]
-   \[Changed] improve number comparison between different types \[[#&#8203;679](https://redirect.github.com/sunng87/handlebars-rust/issues/679)]

</details>

<details>
<summary>mitsuhiko/insta (insta)</summary>

### [`v1.41.0`](https://redirect.github.com/mitsuhiko/insta/blob/HEAD/CHANGELOG.md#1410)

[Compare Source](https://redirect.github.com/mitsuhiko/insta/compare/1.40.0...1.41.0)

-   Experimental support for binary snapshots.  [#&#8203;610](https://redirect.github.com/mitsuhiko/insta/issues/610) (Florian Plattner)

-   `--force-update-snapshots` now causes `cargo-insta` to write every snapshot, regardless of whether
    snapshots fully match, and now implies `--accept`.  This
    allows for `--force-update-snapshots` to update inline snapshots'
    delimiters and indentation.

    For the previous behavior of `--force-update-snapshots`, which limited writes to
    snapshots which didn't fully match, use `--require-full-match`.
    The main difference between `--require-full-match` and the existing behavior of `--force-update-snapshots`
    is a non-zero exit code on any snapshots which don't fully match.

    Like the previous behavior or `--force-update-snapshots`, `--require-full-match`
    doesn't track inline snapshots' delimiters or
    indentation, so can't update if those don't match.  [#&#8203;644](https://redirect.github.com/mitsuhiko/insta/issues/644)

-   Inline snapshots only use `#` characters as delimiters when required.  [#&#8203;603](https://redirect.github.com/mitsuhiko/insta/issues/603)

-   Warnings for undiscovered snapshots are more robust, and include files with
    custom snapshot extensions.  [#&#8203;637](https://redirect.github.com/mitsuhiko/insta/issues/637)

-   Insta runs correctly on packages which reference rust files in a parent path.  [#&#8203;626](https://redirect.github.com/mitsuhiko/insta/issues/626)

-   Warnings are printed when any snapshot uses a legacy format.  [#&#8203;599](https://redirect.github.com/mitsuhiko/insta/issues/599)

-   `cargo insta --version` now prints a version.  [#&#8203;665](https://redirect.github.com/mitsuhiko/insta/issues/665)

-   `insta` now internally uses `INSTA_UPDATE=force` rather than
    `INSTA_FORCE_UPDATE=1`.  (This doesn't affect users of `cargo-insta`, which
    handles this internally.)  [#&#8203;482](https://redirect.github.com/mitsuhiko/insta/issues/482)

-   `cargo-insta`'s integration tests continue to grow over the past couple of versions,
    and now offer coverage of most of `cargo-insta`'s interface.

</details>

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

### [`v0.2.25`](https://redirect.github.com/dtolnay/prettyplease/releases/tag/0.2.25)

[Compare Source](https://redirect.github.com/dtolnay/prettyplease/compare/0.2.24...0.2.25)

-   Print safe and explicitly unsafe foreign items ([#&#8203;85](https://redirect.github.com/dtolnay/prettyplease/issues/85), [https://github.com/rust-lang/rust/issues/123743](https://redirect.github.com/rust-lang/rust/issues/123743))

</details>

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

### [`v1.11.1`](https://redirect.github.com/rust-lang/regex/blob/HEAD/CHANGELOG.md#1111-2024-10-24)

[Compare Source](https://redirect.github.com/rust-lang/regex/compare/1.11.0...1.11.1)

\===================
This is a new patch release of `regex` that fixes compilation on nightly
Rust when the unstable `pattern` crate feature is enabled. Users on nightly
Rust without this feature enabled are unaffected.

Bug fixes:

-   [BUG #&#8203;1231](https://redirect.github.com/rust-lang/regex/issues/1231):
    Fix the `Pattern` trait implementation as a result of nightly API breakage.

</details>

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

### [`v0.0.3`](https://redirect.github.com/saphyr-rs/saphyr/compare/v0.0.1...v0.0.3)

[Compare Source](https://redirect.github.com/saphyr-rs/saphyr/compare/v0.0.1...v0.0.3)

</details>

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

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

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

-   Fix support for macro-generated `with` attributes inside a newtype struct ([#&#8203;2847](https://redirect.github.com/serde-rs/serde/issues/2847))

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

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

-   Fix hygiene of macro-generated local variable accesses in serde(with) wrappers ([#&#8203;2845](https://redirect.github.com/serde-rs/serde/issues/2845))

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

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

-   Improve error reporting about mismatched signature in `with` and `default` attributes ([#&#8203;2558](https://redirect.github.com/serde-rs/serde/issues/2558), thanks [@&#8203;Mingun](https://redirect.github.com/Mingun))
-   Show variant aliases in error message when variant deserialization fails ([#&#8203;2566](https://redirect.github.com/serde-rs/serde/issues/2566), thanks [@&#8203;Mingun](https://redirect.github.com/Mingun))
-   Improve binary size of untagged enum and internally tagged enum deserialization by about 12% ([#&#8203;2821](https://redirect.github.com/serde-rs/serde/issues/2821))

</details>

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

### [`v1.41.0`](https://redirect.github.com/tokio-rs/tokio/releases/tag/tokio-1.41.0): Tokio v1.41.0

[Compare Source](https://redirect.github.com/tokio-rs/tokio/compare/tokio-1.40.0...tokio-1.41.0)

##### 1.41.0 (Oct 22th, 2024)

##### Added

-   metrics: stabilize `global_queue_depth` ([#&#8203;6854], [#&#8203;6918])
-   net: add conversions for unix `SocketAddr` ([#&#8203;6868])
-   sync: add `watch::Sender::sender_count` ([#&#8203;6836])
-   sync: add `mpsc::Receiver::blocking_recv_many` ([#&#8203;6867])
-   task: stabilize `Id` apis ([#&#8203;6793], [#&#8203;6891])

##### Added (unstable)

-   metrics: add H2 Histogram option to improve histogram granularity ([#&#8203;6897])
-   metrics: rename some histogram apis ([#&#8203;6924])
-   runtime: add `LocalRuntime` ([#&#8203;6808])

##### Changed

-   runtime: box futures larger than 16k on release mode ([#&#8203;6826])
-   sync: add `#[must_use]` to `Notified` ([#&#8203;6828])
-   sync: make `watch` cooperative ([#&#8203;6846])
-   sync: make `broadcast::Receiver` cooperative ([#&#8203;6870])
-   task: add task size to tracing instrumentation ([#&#8203;6881])
-   wasm: enable `cfg_fs` for `wasi` target ([#&#8203;6822])

##### Fixed

-   net: fix regression of abstract socket path in unix socket ([#&#8203;6838])

##### Documented

-   io: recommend `OwnedFd` with `AsyncFd` ([#&#8203;6821])
-   io: document cancel safety of `AsyncFd` methods ([#&#8203;6890])
-   macros: render more comprehensible documentation for `join` and `try_join` ([#&#8203;6814], [#&#8203;6841])
-   net: fix swapped examples for `TcpSocket::set_nodelay` and `TcpSocket::nodelay` ([#&#8203;6840])
-   sync: document runtime compatibility ([#&#8203;6833])

[#&#8203;6793]: https://redirect.github.com/tokio-rs/tokio/pull/6793

[#&#8203;6808]: https://redirect.github.com/tokio-rs/tokio/pull/6808

[#&#8203;6810]: https://redirect.github.com/tokio-rs/tokio/pull/6810

[#&#8203;6814]: https://redirect.github.com/tokio-rs/tokio/pull/6814

[#&#8203;6821]: https://redirect.github.com/tokio-rs/tokio/pull/6821

[#&#8203;6822]: https://redirect.github.com/tokio-rs/tokio/pull/6822

[#&#8203;6826]: https://redirect.github.com/tokio-rs/tokio/pull/6826

[#&#8203;6828]: https://redirect.github.com/tokio-rs/tokio/pull/6828

[#&#8203;6833]: https://redirect.github.com/tokio-rs/tokio/pull/6833

[#&#8203;6836]: https://redirect.github.com/tokio-rs/tokio/pull/6836

[#&#8203;6838]: https://redirect.github.com/tokio-rs/tokio/pull/6838

[#&#8203;6840]: https://redirect.github.com/tokio-rs/tokio/pull/6840

[#&#8203;6841]: https://redirect.github.com/tokio-rs/tokio/pull/6841

[#&#8203;6846]: https://redirect.github.com/tokio-rs/tokio/pull/6846

[#&#8203;6854]: https://redirect.github.com/tokio-rs/tokio/pull/6854

[#&#8203;6867]: https://redirect.github.com/tokio-rs/tokio/pull/6867

[#&#8203;6868]: https://redirect.github.com/tokio-rs/tokio/pull/6868

[#&#8203;6870]: https://redirect.github.com/tokio-rs/tokio/pull/6870

[#&#8203;6881]: https://redirect.github.com/tokio-rs/tokio/pull/6881

[#&#8203;6890]: https://redirect.github.com/tokio-rs/tokio/pull/6890

[#&#8203;6891]: https://redirect.github.com/tokio-rs/tokio/pull/6891

[#&#8203;6897]: https://redirect.github.com/tokio-rs/tokio/pull/6897

[#&#8203;6918]: https://redirect.github.com/tokio-rs/tokio/pull/6918

[#&#8203;6924]: https://redirect.github.com/tokio-rs/tokio/pull/6924

</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 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:eyJjcmVhdGVkSW5WZXIiOiIzOC4xMjAuMSIsInVwZGF0ZWRJblZlciI6IjM4LjEyMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
2024-10-28 06:22:28 +00:00
Boshen
6d97af46c7 feat(rust): use oxc-miette (#6938) 2024-10-27 13:30:20 +00:00
Boshen
4dc5e51cb1 fix(transformer): only run typescript plugin for typescript source (#6889)
closes #6865

TypeScript plugin changes import / export statements so it needs to be turned off for non-typescript files. This should also give a little performance boost for non-typescript files.
2024-10-25 13:59:31 +00:00
Boshen
4618aa22d9 refactor(transformer)!: rename TransformerOptions::react to jsx (#6888) 2024-10-25 12:04:33 +00:00
leaysgur
90c786c420 feat(regular_expression)!: Support ES2025 Duplicated named capture groups (#6847)
Closes #6358

@preyneyv I know you've been working on this problem.

This is an implementation that has been dormant on my local for a while.

- All tests are passing
- However, the approach is simple but not general, so there might be some edge cases that were missed
- There's also room for improvement in terms of performance

For these reasons, it was marked as WIP for me.

I believe the test cases and other parts are usable, so feel free to fork and replace them with your implementation if you'd like.
2024-10-25 02:13:57 +00:00
Boshen
a47c70e425 fix(minifier): fix remaining runtime bugs (#6855) 2024-10-24 12:22:18 +00:00
Boshen
686727fc96 fix(minifier): reference read has side effect (#6851) 2024-10-24 08:32:38 +00:00
Dunqing
076f5c39f4 fix(transformer/typescript): retain ExportNamedDeclaration without specifiers and declaration (#6848)
close: #6825
2024-10-24 07:59:07 +00:00
Boshen
fd57e00108 feat(ecmascript): add abstract_relational_comparison to dce (#6846)
I removed bigint comparisons because they were incorrect
2024-10-24 06:46:07 +00:00
Boshen
ca799936b0 fix(minifier): do not dce object literals yet (#6839)
closes #6769
2024-10-24 01:05:07 +00:00
Boshen
ec5a19b880 fix(minifier): do not remove binary expressions (#6829) 2024-10-23 16:07:29 +00:00
Boshen
22355f73f3 fix(minifier): do not remove undefined for destructuring patterns (#6828) 2024-10-23 15:42:04 +00:00
Boshen
088c1b6460 fix(coverage): turn off mangle for runtime test (#6827) 2024-10-23 15:05:36 +00:00
Boshen
7291f71019 fix(coverage): enable only_remove_type_imports for runtime transform test (#6826) 2024-10-23 14:26:48 +00:00
Boshen
11077708bb fix(coverage): inject babel helpers for transform (#6818) 2024-10-23 12:43:56 +00:00
Boshen
4757376136 fix(coverage): omit explicit-resource-management from runtime test (#6804) 2024-10-23 07:49:01 +00:00
Boshen
05ef03dbab fix(codegen): correct print __proto__ shorthand (#6802) 2024-10-23 07:16:00 +00:00
Boshen
1b7897cf01 fix(codegen): print #field in {} << 0; correctly (#6799) 2024-10-23 05:34:22 +00:00
Boshen
2f6ad42348 fix(codegen): print negative bigint 1n- -1n correctly after constant folding (#6798)
closes #6767
2024-10-23 04:56:50 +00:00