Commit graph

397 commits

Author SHA1 Message Date
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
overlookmotel
e19deaa102 ci(transformer): move post-transform checker to tasks crate (#6288)
Move post-transform checker into a `tasks` crate. It doesn't feel like it belongs in `oxc_semantic`. It also feels like too heavy a lump of code to put in `tasks/common`.
2024-10-05 14:48:37 +00:00
overlookmotel
0f5afd7ede test(transformer): transform checker output symbol name for mismatches (#6286)
Transform checker include symbol names in output for symbol mismatches. This is rather more helpful for locating bugs than just `SymbolId(3)`.
2024-10-05 14:42:06 +00:00
overlookmotel
21b08ba141 refactor(transformer): shared VarDeclarations (#6170)
First step towards #5049.

Various transforms need to add a `var` statement at top of enclosing statement block.

e.g.:

```js
// Input
a ??= b;
```

```js
// Output
var _a;
(_a = a) !== null && _a !== void 0 ? _a : (a = b);
```

Each of these transforms previously maintained it's own stack and added `var` statements individually.

Share this functionality in a "common" utility transform which maintains a single stack to serve them all.
2024-09-30 03:53:00 +00:00
Dunqing
bfd19882b0 fix(transformer/react): should not collect use-hooks if it's a nested member expression (#6143)
close: #6139

I still remember this logic and I call `get_first_object` for it intentionally 🥲
2024-09-28 14:38:14 +00:00
DonIsaac
b1af73db81 fix(semantic): do not create a global symbol for declare global {} (#6040)
Re-creation of #6004 to unblock it from down-stack PRs. @Boshen has already reviewed the previous PR and determined this to be correct behavior.
2024-09-25 08:46:00 +00:00
Boshen
28da77195b feat(transformer): do not transform ** with bigint literals (#6023)
part of #5822

They will produce runtime errors.
2024-09-24 10:33:02 +00:00
overlookmotel
4e9e838838 fix(transformer): fix arrow function transform (#5933)
Fix arrow function transform's treatment of `this` within classes.
2024-09-21 07:48:18 +00:00
overlookmotel
15743344b1 test(transformer): add test for arrow function transform (#5932)
Add test for `this` in nested block inside arrow function.
2024-09-21 00:53:43 +00:00
Boshen
6757c5829f
chore(transform_conformance): remove unused snapshots/typescript.snap.md
closes #5922
2024-09-20 22:41:41 +08:00
overlookmotel
bd318b1eec test(transformer): join paths in cross-platform compatible way (#5920) 2024-09-20 11:30:12 +00:00
overlookmotel
7d32d2086c
test(transformer): update transform conformance README (#5919)
Add reference to our additional tests + tidy up capitalization.
2024-09-20 11:46:44 +01:00
overlookmotel
9dac6dfb23 test(transformer): move transformer conformance snapshots into separate directory (#5917)
Move snapshots for transform conformance into a `snapshots` sub-folder.
2024-09-20 10:25:17 +00:00
overlookmotel
4d5c4f6cad fix(transformer): fix reference flags in logical assignment operator transform (#5903) 2024-09-20 01:26:55 +00:00
overlookmotel
d335a6760e fix(transformer): fix references in logical assignment operator transform (#5896)
Re-use existing reference, rather than creating a new one.
2024-09-20 01:26:53 +00:00
overlookmotel
cab441c572 test(transformer): fix JSX test options (#5895)
Fix a test by setting correct options.
2024-09-20 01:26:52 +00:00
overlookmotel
9758c1a5cc fix(transformer): JSX source: add var _jsxFileName statement (#5894)
Fix JSX source transform when run alone without main JSX transform.

The added test case is same as one of Babel's exec test cases, but the exec test fails due to `transformAsync` not being present.
2024-09-20 01:26:52 +00:00
overlookmotel
0c8733df23 test(transformer): clean up identation in test fixtures (#5863)
Not sure how added up with mix of tabs and spaces.
2024-09-18 15:19:59 +00:00
overlookmotel
ef8dcc9d4d test(transformer): more tests for arrow function transform (#5849) 2024-09-18 09:46:58 +00:00
overlookmotel
49ee1dcff2 fix(transformer): arrow function transform handle this in arrow function in class static block (#5848)
Class static blocks also hold a `this` binding.
2024-09-18 09:46:57 +00:00
Boshen
213dbc04ff chore(transform_conformance): do not print comments yet (#5788) 2024-09-15 15:48:58 +00:00
Dunqing
36e698b411 perf(transformer): call transform_jsx in exit_expression rather than enter_expression (#5751)
### Difference

In `enter_expression`: Recursive transform JSX
In `exit_expression`: Deep first transform

After the change,  `transform_jsx` still has a lot of room for improvement.
2024-09-13 17:58:41 +00:00
Dunqing
3cc38dfc05 fix(transformer/react): react refresh panics when encounter use hook (#5768)
close: #5766

I even forgot that React has a `use` hook in the latest version
2024-09-13 16:17:33 +00:00
Dunqing
77d9170f84 fix(transformer/react): isStaticChildren should be false when there is only one child (#5745)
We found a warning report [here](206df66e70/packages/react/src/jsx/ReactJSXElement.js (L614-L632)). It caused by we transform incorrectly
2024-09-13 13:20:59 +00:00
Dunqing
c9fea5dd16 chore(tasks/transformer_conformance): remove an ignored test that has passed (#5750) 2024-09-13 09:03:48 +00:00
dalaoshu
d18c896a2c
perf(rust): use cow_utils instead (#5664)
Related to #5586 and #5662

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-09-11 18:39:30 +08:00
Dunqing
a1afd48c68 fix(transformer/react): incorrect scope_id for var hoisted in fast refresh plugin (#5695)
Fix the last one semantic error in the fast react plugin
2024-09-11 09:02:29 +00:00
Dunqing
f2f5e5aaf5 fix(transformer/react): missing scope_id for function in fast refresh plugin (#5693)
Fix semantic error in the fast react plugin
2024-09-11 09:02:28 +00:00
Dunqing
a891c31889 fix(transformer/react): refresh plugin has incorrect reference flags (#5656)
As you see the diff
2024-09-11 07:57:17 +00:00
Dunqing
ffbc4625b4 chore(transformer): treat all React Refresh tests as ESM syntax (#5644)
related: #5612
2024-09-11 07:57:17 +00:00
Dunqing
3e8b96f165 fix(transformer/react): the refresh plugin cannot handle member expressions with React hooks (#5655)
The previous implementation doesn't handle nested StaticMemberExpression. For example: `A.B.C.useHook`.
2024-09-11 07:57:16 +00:00