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.
Rename transform conformance RegExp test fixtures folder from "esbuild-tests" to "regexp", to reflect that not all these tests are copied from ESBuild.
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
close: #3943
## Further improvements
There is a double visit here. We need to collect all react hooks calling in `Function` and `ArrowFunctionExpression`. If we want to remove this implementation, we may wait for #4188.
d797e595d2/crates/oxc_transformer/src/react/refresh.rs (L744-L947)
## Tests
All tests copy from https://github.com/facebook/react/blob/main/packages/react-refresh/src/__tests__/ReactFresh-test.js
There are still 4 tests that have not been passed
**1. refresh/can-handle-implicit-arrow-returns/input.jsx**
Related to #4767. transform correct, just output doesn't match the expected output
**2. refresh/registers-identifiers-used-in-jsx-at-definition-site/input.jsx**
**3. refresh/registers-identifiers-used-in-react-create-element-at-definition-site/input.jsx**
Blocked by #4746
**4. refresh/supports-typescript-namespace-syntax/input.tsx**
oxc transforms ts to js first, so probably we can ignore this case. If we really want to pass this test, we also need to turn off `TypeScript` plugin.
## What's next?
### Options:
1. Support transform `refresh_reg` and `refresh_sig` options to `MemberExpression`. Currently `import.meta.xxxx` still is an `Identifier`
2. Support `emit_full_signatures` option
### Other
NAPI, testing in `monitor-oxc`, etc..
close: #3620
In `Babel`, the expected output is:
```ts
var x = 10;
var Foo = function(Foo) {
Foo[Foo['a'] = 10] = 'a';
Foo[Foo['b'] = 10] = 'b';
Foo[Foo['c'] = 30] = 'c';
return Foo;
}(Foo || {});
```
IMO, `Foo.b + x` is enough, because `x` is not a const variable. The
output same as with `typescript`
The remaining test cases will perform better with a scope
implementation, and while we can implement them without the scope, it
still requires us to do what the scope did.
---------
Co-authored-by: Boshen <boshenc@gmail.com>
Related to:
https://github.com/oxc-project/oxc/pull/2822#issuecomment-2021802212
Although `babel` has a lot of test cases, we still need to add edge
cases that `babel` doesn't have.
This PR will allow us to add out test cases to
`/root/oxc/tasks/transform_conformance/tests`. The directory structure
is consistent with `babel`
For example
```shell
# cd /root/oxc/tasks/transform_conformance/tests
- babel-transform-plugin–optional-catch-binding
- test
- fixtures
- your tests # add test cases here
```