Commit graph

371 commits

Author SHA1 Message Date
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
Dunqing
7b543dffd9 feat(transformer/react): handle refresh_sig and refresh_reg options correctly (#5638)
In previous implementations, even if pass `import.meta.xxxx` into these options this plugin still treats them as `IdentifierReference`
2024-09-11 07:57:15 +00:00
Dunqing
3bf6aaf06a fix(transformer/react): support emit_full_signatures option in refresh plugin (#5629) 2024-09-11 07:57:14 +00:00
Dunqing
36d864a0c3 fix(transformer/react): don't transform if the variable does not have a value reference (#5528)
close: #4746

Solved the last two tests, but it's a coincidence. I've added a test to cover it.
2024-09-11 07:10:55 +00:00
Boshen
f49e6ebd41 fix(span): treat .js as module file (reverts the previous breaking change) (#5612)
As it turns out it's not ideal to treat `.js` as `script` in today's world anymore.

This makes https://github.com/oxc-project/oxlint-ecosystem-ci pass again.
2024-09-08 15:14:04 +00:00
Boshen
63a830e08c
chore(dprint): format toml files (#5599)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-08 14:26:16 +08:00
Boshen
919d17fc5c fix(transform_conformance): only print semantic mismatch errors when output is correct (#5589)
closes #5166

Had to rerun for mismatch errors :-/
2024-09-07 16:32:53 +00:00
overlookmotel
505d06446b fix(transformer): JSX transform delete references for JSXClosingElements (#5560)
JSX transform delete old references which were used in `JSXClosingElement` before transformation.
2024-09-07 03:51:36 +00:00
overlookmotel
87a79d9cd0 test(transformer): add trailing line breaks to conformance fixtures (#5537)
Currently whether conformance fixture files have trailing line breaks is inconsistent - some have them, some don't. Make all of them have a trailing line break.
2024-09-06 12:02:46 +00:00
overlookmotel
e18c2edfcb test(transformer): move RegExp transform conformance tests (#5536)
Rename transform conformance RegExp test fixtures folder from "esbuild-tests" to "regexp", to reflect that not all these tests are copied from ESBuild.
2024-09-06 12:02:45 +00:00
overlookmotel
d1ece197c4 fix(transformer): RegExp transform handle Term::Quantifier (#5501)
`Term::Quantifier` contains a nested `Term` so we need to recurse into that `Term` to check if it contains any unsupported syntax.
2024-09-06 11:51:35 +00:00
Boshen
1bed5ce2a5 chore: run cargo +nightly fmt to sort imports (#5503)
They are never going to be stable are they ... cedf7a4daa/.rustfmt.toml (L8-L16)
2024-09-06 04:04:26 +00:00
Dunqing
c59d8b3c9b feat(transformer): support all /regex/ to new RegExp transforms (#5387)
related: #4754

The implementation port from [esbuild](332727499e/internal/js_parser/js_parser.go (L12820-L12840)). And cover all babel's regexp plugins

---

## The following description was generated by `Graphite` 😋

### TL;DR

Added support for transforming various RegExp features to ensure compatibility with older JavaScript environments.

### What changed?

- Implemented a new `RegExp` transformer to handle unsupported RegExp literal features
- Added options to control different RegExp transformations (e.g., sticky flag, unicode flag, dot-all flag, etc.)
- Updated the transformer to convert unsupported RegExp literals into `new RegExp()` constructor calls
- Added test cases for different RegExp transformations
- Integrated the new RegExp transformer into the existing transformation pipeline

### How to test?

1. Run the existing test suite to ensure no regressions
2. Execute the new RegExp-specific tests in the `tasks/transform_conformance/tests/esbuild-tests/test/fixtures/regexp/` directory
3. Try transforming code with various RegExp features using different target environments to verify correct transformations
2024-09-05 11:04:45 +00:00
overlookmotel
cba93f52d0 feat(ast)!: add ThisExpression variants to JSXElementName and JSXMemberExpressionObject (#5466)
Close #5352.

Add to AST:

* `JSXElementName::ThisExpression` (`<this>`)
* `JSXMemberExpressionObject::ThisExpression` (`<this.foo>`, `<this.foo.bar>`)
2024-09-05 02:06:20 +00:00
Dunqing
0617249716 fix(transformer/nullish-coalescing-operator): incorrect reference flags (#5408)
Fixes an obvious problem
2024-09-03 15:29:07 +00:00
overlookmotel
cfe54974f1 fix(transformer): do not create double reference in JSX transform (#5414)
Follow on after #5358. Don't create a new `IdentifierReference` with a new `ReferenceId` when we already have one which is correctly resolved.
2024-09-03 15:06:07 +00:00
overlookmotel
b9ef357868 test(transformer): add tests for nested JSX this member expressions in arrow function transform (#5413)
Follow-up after #5356. Handle nested JSX member expressions with `this` as base object in arrow functions transform (e.g. `<this.foo.bar />`).
2024-09-03 15:06:06 +00:00
Dunqing
0eb32a6770 fix(traverse): invalid variable name generated by generate_uid_based_on_node (#5407)
close: #5371
2024-09-03 12:13:30 +00:00
Dunqing
0abfc5049f feat(transformer/typescript): support rewrite_import_extensions option (#5399)
close: #5395

Babel only supports `rewrite`, we also support `remove`
2024-09-03 01:57:42 +00:00
overlookmotel
be4642fc02 feat(semantic): transform checker check child scope IDs (#5410)
Transform checker check child scope IDs. If we have to track child scope IDs, we should make sure they're correct!
2024-09-03 00:57:13 +00:00
Dunqing
1aa49af010 feat(ast)!: remove JSXMemberExpressionObject::Identifier variant (#5358)
close: #5353

`JSXMemberExpressionObject::Identifier` is dead code.
2024-09-02 18:35:39 +00:00
Dunqing
94ff94cd34 fix(transformer/arrow-functions): reaches unreachable when <this.foo> is inside an arrow function (#5356)
Fixes: https://github.com/oxc-project/oxc/issues/5353#issuecomment-2321792915
2024-09-02 18:06:08 +00:00
Dunqing
35f03db464 fix(transformer): ArrowfunctionExpression's expression is true but has more than one body statement (#5366)
close: #5363

We insert the new statement here, but it's broken if it a `() => x;`, we need to transform it to `function () { return x }`

8d565d5b23/crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs (L59-L76)

I don't where we should put the fallback logic, It's useful for all plugins. We had already done the same thing in the react refresh plugin.

8d565d5b23/crates/oxc_transformer/src/react/refresh.rs (L578-L605)
2024-08-31 14:49:58 +00:00
Boshen
e75e0f1465 chore: update test262 / babel / typescript submodules (#5369)
closes #5215
2024-08-31 12:28:25 +00:00
Dunqing
32f730085c feat(ast)!: add JSXElementName::IdentifierReference and JSXMemberExpressionObject::IdentifierReference (#5223)
close: #3528

part of #4746
2024-08-30 11:11:04 +00:00
DonIsaac
cd63336c7e refactor(diagnostic): change how diagnostic codes are rendered (#5317)
Preparation for upstack PRs. Graphical reporter diagnostics look exactly the same. This does, however, change `to_string()` to only show diagnostic messages, and not error codes + messages.
2024-08-29 05:50:03 +00:00
Dunqing
3acb3f6461 fix(transformer/react): mismatch output caused by incorrect transformation ordering (#5255)
close: #4767
2024-08-29 00:38:02 +00:00