Commit graph

427 commits

Author SHA1 Message Date
Boshen
6e1abde5ef chore(transform_conformance): omit tests that we cannot pass right now (#7192) 2024-11-07 14:20:30 +00:00
Boshen
a579011e37 feat(transformer): add features ES2018NamedCapturingGroupsRegex and ES2018LookbehindRegex (#7182) 2024-11-07 07:39:33 +00:00
Boshen
ad3a2f518e feat(tasks/compat_data): generate our own compat table (#7176) 2024-11-07 07:39:33 +00:00
renovate
3da9443b0e chore(deps): update dependency @types/node to v22.9.0 (#7145)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@types/node](https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | [`22.8.4` -> `22.9.0`](https://renovatebot.com/diffs/npm/@types%2fnode/22.8.4/22.9.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/22.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/22.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/22.8.4/22.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/22.8.4/22.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### 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.

🔕 **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://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xNDIuNyIsInVwZGF0ZWRJblZlciI6IjM4LjE0Mi43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
2024-11-06 06:17:36 +00:00
Dunqing
b2a888df0d fix(transformer/async-generator-functions): incorrect transformation for for await if it's not placed in a block (#7148)
Found in https://github.com/oxc-project/monitor-oxc/actions/runs/11681867380/job/32527898715
2024-11-06 05:51:01 +00:00
Dunqing
19892ede40 fix(transformer/async-generator-functions): transform incorrectly for for await if it's in LabeledStatement (#7147)
Found in https://github.com/oxc-project/monitor-oxc/actions/runs/11681867380/job/32527898715
2024-11-06 03:27:14 +00:00
Dunqing
cd1006fec1 refactor(transformer/async-generator-functions): do not transform yield expression where inside generator function (#7134) 2024-11-06 03:27:13 +00:00
Dunqing
2c5734d49b refactor(transformer/async-generator-functions): do not transform await expression where inside ArrowFunctionExpression (#7132)
The `await expr` should be transformed in AsyncToGenerator rather than AsyncGeneratorFunctions
2024-11-06 03:27:12 +00:00
Dunqing
b6a575009a feat(transformer/arrow-function-converter): move scope to changed scope for this_var if scope have changed (#7125)
The scope can be moved or deleted, we need to check whether the scope id is the same as the container's scope id, if not, we need to move the `this_var` to the target scope id.
2024-11-06 03:02:36 +00:00
Dunqing
df772411ea feat(transformer): enable ArrowFunctionConverter in async-to-generator and async-generator-functions plugins (#7113)
Part of https://github.com/oxc-project/oxc/pull/7074

In async-to-generator and async-generator-functions plugins, we may need to transform the async arrow function to a regular generator function, now we can reuse the ability of the ArrowFunction plugin by enabling `ArrowFunctionConverter`.

I will fix semantic errors in the follow-up PR
2024-11-06 03:02:36 +00:00
Boshen
9386435efb
feat(transform_conformance): use node instead of bun for exec tests (#7121) 2024-11-05 14:20:48 +08:00
Boshen
c2802e63fc feat(transform_conformance): add babel runtime to exec tests (#7114) 2024-11-04 14:38:15 +00:00
Dunqing
f80085c683 refactor(transformer/async-to-generator): move handling of MethodDefinition's value to exit_function (#7105)
Part of #7074

We need to handle this before the `arrow_function` plugin inserts `_this = this` because, in the `async-to-generator` plugin, we will move the body to an inner generator function. However, we don't want `_this = this` moved to the inner generator function as well. So as long as we move first, and then insert, we can fix this problem.

The new semantic error is related to another tricky problem, I will fix it in another PR
2024-11-04 14:32:42 +00:00
Dunqing
a2244ff089 fix(transformer/async-to-generator): output is incorrect when arrow function without params (#7052) 2024-11-01 15:35:57 +00:00
Boshen
f83a760d8a refactor(transformer): deserialize BabelOptions::presets (#7047) 2024-11-01 06:56:27 +00:00
Boshen
52c20d633c refactor(transformer): deserialize BabelOptions::plugins (#7045) 2024-11-01 05:44:57 +00:00
Dunqing
934cb5e746 feat(transformer): add async_generator_functions plugin (#6573)
Passed 15/19 tests. The remaining 4 failed tests related to `this` expression, the problem same as I mentioned in #6658. I will fix them in follow-up PRs.
2024-10-31 09:14:17 +00:00
overlookmotel
2a57a66753 test(transformer): support exec tests in Oxc folder (#7030)
Fix error when `tasks/transform_conformance/tests` contains exec tests.
2024-10-31 01:18:09 +00:00
Boshen
76947e2aec refactor(transform): refactor Babel Targets (#7026)
Found a trick from serde to get us from `BabelTargets` to `Targets`.
2024-10-30 14:08:19 +00:00
Boshen
b8daab3663 refactor(transformer)!: API to TryFrom<&EnvOptions> for TransformOptions and TryFrom<&BabelOptions> TransformOptions (#7020)
…ions` and `TryFrom<&BabelOptions> TransformOptions`
2024-10-30 09:40:09 +00:00
Dunqing
1ca8cd2fd9 refactor(transformer/react-refresh): avoid panic for init of VariableDeclarator isn't a BindingIdentifier (#6937)
related: https://github.com/oxc-project/oxc/pull/6881#discussion_r1816597462
2024-10-28 01:19:53 +00:00
Boshen
6d97af46c7 feat(rust): use oxc-miette (#6938) 2024-10-27 13:30:20 +00:00
Dunqing
5f153aca0c refactor(transformer/react-refresh): use VarDeclarations to insert declarators (#6884) 2024-10-27 07:05:24 +00:00
Dunqing
142da1d2ff chore(transform_conformance): reorganize react-refresh related tests (#6918)
Move all tests that are copied from [react-refresh](https://github.com/facebook/react/blob/main/packages/react-refresh/src/__tests__/ReactFreshBabelPlugin-test.js) to the `react-refresh` directory, and add a README to describe the source of these tests. This way we can better stay in sync with upstream.

related: https://github.com/oxc-project/oxc/pull/6884#discussion_r1816888813
2024-10-26 13:07:10 +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
Dunqing
0d0bb17ad9 feat(transformer): complete the async-to-generator plugin (#6658)
In this PR, most of the async functions have transformed correctly. But the async arrow functions don't fully transform correctly yet, it is related to we need to transform the arrow function to the generator function. For example:

Input:
```js
function declaration() {
  const asy = async () => {
  console.log(this.name)
 }
}
```

Output:
```js
function declaration() {
  const asy = babelHelpers.asyncToGenerator(function* () {
     console.log(this.name);
  });
}
```

Expected Output:

```js
function declaration() {
  var _this = this;
  const asy = /*#__PURE__*/function () {
    var _ref = babelHelpers.asyncToGenerator(function* () {
      console.log(_this.name);
    });
    return function asy() {
      return _ref.apply(this, arguments);
    };
  }();
}
```

From the expected output, we haven't handled `this` correctly, which means even if the `arrow-function` plugin doesn't enable, we still need to handle this correctly as the `arrow-function` plugin does, and further question if `arrow-function` plugin is enabled, how to avoid these making conflict?

I thought we may move out the implementation of `arrow-function` and as a common helper, this way every plugin can handle this well
2024-10-25 03:23:31 +00:00
Dunqing
076f5c39f4 fix(transformer/typescript): retain ExportNamedDeclaration without specifiers and declaration (#6848)
close: #6825
2024-10-24 07:59:07 +00:00
overlookmotel
10484cdeeb feat(transformer): class static block transform (#6733)
Add ES2022 class static block transform.
2024-10-22 03:40:02 +00:00
Boshen
3711c32f22 chore(coverage): bump test262, babel and TypeScript (#6702)
closes #6692
2024-10-20 15:02:26 +00:00
magic-akari
1d3d256db3 fix(transformer): Correctly trim JSX (#6639)
- Closes: #6638
2024-10-17 14:41:02 +00:00
Dunqing
a3dea9c542 feat(transformer/async-to-generator): handle arrow-function correctly (#6640) 2024-10-17 08:47:28 +00:00
Dunqing
673b66620b chore(transform_conformance): do not extend plugins if current options has plugins (#6627)
I saw many tests were ignored even if they don't contain any unsupported plugins
2024-10-17 02:07:03 +00:00
Ethan Goh
a9260cf6d1
feat(transformer): async-to-generator plugin. (#5590)
Tests are still not passed. A lot need to do yet.

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-10-14 17:16:58 +08:00
Boshen
7645e5c34b refactor(codegen)!: remove CommentOptions API (#6451) 2024-10-11 13:53:28 +00:00
overlookmotel
073b02af14 refactor(ast): type params field before params in TS function declaration types (#6391)
Our convention is that AST type fields are ordered in order they appear in source. Move `type_parameters` fields in TS function declaration types to before `this_param` and formal parameters.
2024-10-11 09:57:28 +00:00
Boshen
520096030a refactor(oxc)!: remove passing Trivias around (#6446)
part of #6426
2024-10-11 06:09:25 +00:00
Boshen
2b7be08af4 feat(ast)! add source_text to Program (#6444) 2024-10-11 04:13:41 +00:00
overlookmotel
4fd89e8eed test(transformer): fix indentation in transformer test fixtures (#6346)
Unimportant nit. Fix whitespace in the transformer test fixtures.
2024-10-08 01:32:07 +00:00
overlookmotel
cf20f3a89d feat(transformer): exponentiation transform: support private fields (#6345)
Babel doesn't support private fields in this transform, but there's no reason not to. So we can.
2024-10-08 01:32:06 +00:00
overlookmotel
4aa4e6bec0 refactor(transformer): exponentiation transform: do not wrap in SequenceExpression if not needed (#6343)
`left **= right` is transformed to `left = Math.pow(left, right)`. There is no need to wrap it in a `SequenceExpression`.
2024-10-08 01:32:05 +00:00
overlookmotel
2bcd12a868 fix(transformer): exponentiation transform: fix reference flags (#6330) 2024-10-07 10:35:34 +00:00
overlookmotel
28cbfa7c64 fix(transformer): exponentiation transform: fix temp var names (#6329)
Fix one case that I missed in #6318.
2024-10-07 09:00:35 +00:00
overlookmotel
3a4bcc77fc fix(transformer): exponentiation transform: fix temp var names (#6318)
Make naming of temp vars follow Babel. It wasn't apparent that our version of this transform was behaving differently from Babel because the Babel plugin has very few tests. The added tests replicate Babel's output.
2024-10-06 23:08:10 +00:00
overlookmotel
ccb7bdcc56 fix(transformer): exponentiation transform: do not replace object when private property (#6313)
Fix exponentiation operator transform to bail out early if a private class property.

We can't transform this:

```js
class C {
    #p;
    method() {
        this.#p **= 2;
    }
}
```

But we should at least leave it alone. Previously `get_obj_ref` called `ast.move_expression(expr)` on the member expression's object before bailing out, so example above was transformed to:

```js
class C {
    #p;
    method() {
        null.#p **= 2; // <-- `null`
    }
}
```

This PR makes it spot this case early and bail out *before* calling `ast.move_expression(expr)`.
2024-10-06 23:08:08 +00:00
Boshen
020bb80b65 refactor(codegen)!: change to CodegenReturn::code and CodegenReturn::map (#6310) 2024-10-06 05:05:47 +00:00
overlookmotel
bd81c5134c fix(transformer): exponentiation transform: fix duplicate symbols (#6300)
Identifier was being cloned unnecessarily, creating an extra symbol.
2024-10-06 00:51:28 +00:00
Boshen
8729755baa feat(oxc,napi/transform): napi/transform use oxc compiler pipeline (#6298)
part of #6156
2024-10-05 16:35:09 +00:00
overlookmotel
409dffc8ab refactor(traverse)!: generate_uid return a BoundIdentifier (#6294)
Closes #5020.

`TraverseCtx::generate_uid` and associated methods return a `BoundIdentifier`, containing both symbol ID and name. This reduces boilerplate code for the caller and avoids and unnecessary lookup to get the name.

Also add a couple of helper methods to `BoundIdentifier` to reduce boilerplate further.
2024-10-05 16:00:50 +00:00
overlookmotel
06797b6900 fix(transformer): logical assignment operator transform: fix reference IDs (#6289) 2024-10-05 14:48:37 +00:00