Dunqing
3acb3f6461
fix(transformer/react): mismatch output caused by incorrect transformation ordering ( #5255 )
...
close : #4767
2024-08-29 00:38:02 +00:00
magic-akari
08dc0adeab
feat(transformer): add object-spread plugin ( #3133 )
2024-08-28 15:57:20 +00:00
Boshen
8d6b05ca01
fix(transformer): class property with typescript value should not be removed ( #5298 )
2024-08-28 13:53:41 +00:00
Dunqing
5754c89b5e
fix(transformer/typescript): remove accessibility from AccessorProperty ( #5292 )
...
Regression by #5290
2024-08-28 08:42:38 +00:00
Dunqing
550574982f
feat(ast): add accessibility field to AccessorProperty ( #5290 )
2024-08-28 08:42:37 +00:00
overlookmotel
10861096e0
refactor(semantic): transform checker do not output spans in errors ( #5260 )
...
Transform checker don't output spans in errors. They're inaccurate because (a) spans refer to the source text pre-transform, and (b) most errors relate to scopes/symbols/references newly created in transformer, which have no span.
2024-08-27 11:58:21 +00:00
overlookmotel
af5713e411
refactor(semantic): transform checker continue checks if missing IDs ( #5259 )
...
Transform checker don't bail out if some IDs missing from AST. Continue to check for other problems.
Also simplify iterating over pairs of IDs.
2024-08-27 11:58:20 +00:00
overlookmotel
943454fa5e
refactor(semantic): update transform checker for no conditional scopes ( #5252 )
...
All scopes are now unconditional (#5008 ). Update transform checker to reflect this.
2024-08-27 08:57:15 +00:00
Boshen
a17cf33dc3
refactor(semantic): remove ScopeTree::child_ids ( #5232 )
...
closes https://github.com/oxc-project/oxc/issues/5244
2024-08-27 01:49:47 +00:00
Dunqing
f8bb0222b3
fix(transformer/arrow-functions): remove SymbolFlags::ArrowFunction ( #5190 )
...
`ArrowFunction` has been transforming to `FunctionExpression`, So we should remove `SymbolFlags::ArrowFunction`
2024-08-25 10:27:00 +00:00
Dunqing
d9ba5ad022
fix(transformer/arrow-functions): correct scope for _this ( #5189 )
...
The `_this` will eventually be inserted into a `Program` or `Function`. So we have to go up to the corresponding `scope_id`
2024-08-25 10:26:59 +00:00
Dunqing
056c6679ec
feat(transformer/arrow-functions): the output that uses this inside blocks doesn't match Babel ( #5188 )
...
Fixes 666282a13b/crates/oxc_transformer/src/es2015/arrow_functions.rs (L35-L62)
2024-08-25 10:26:57 +00:00
Boshen
01c0c3e4b2
feat(transformer): add remaining options to transformer options ( #5169 )
...
closes #5168
2024-08-24 14:52:03 +00:00
overlookmotel
eb71a32ee7
refactor(ci): transform conformance snapshot include when output mismatch ( #5135 )
...
Include "Output mismatch" in transform conformance snapshots when a test also fails due to scopes/symbols mismatches.
At present, many of the tests are failing on scopes/symbols mismatches, so it's hard to see from snapshots which also have an output mismatch. In particular, when working to fix scope mismatches, it's hard to notice if changes you make cause the output to be wrong. These extra messages make that visible.
2024-08-24 04:52:14 +00:00
overlookmotel
be42b1c76b
fix(ci): transform conformance do not skip any errors ( #5134 )
...
Snapshots generated by transform conformance were missing a few errors (e.g. `declarations/const-enum/input.ts` at bottom of diff). Make sure all errors fail the test.
2024-08-24 04:52:11 +00:00
Dunqing
47e69a8c94
fix(transformer-optional-catch-binding): the unused binding is not in the correct scope ( #5066 )
...
Blocked by #5008
In the SemanticBuilder, we insert all CatchClause parameters in the BlockStatement scope, a child-scope of CatchClause
858f510d59/crates/oxc_semantic/src/builder.rs (L709-L718)
So we should do the same thing in this plugin, but because CatchClause has no parameters, SemanticBuilder doesn't create scope for `CatchClause`. This cause we cannot find the `BlockStatement` scope_id.
This PR has changed to the correct logic. Just to wait #5008 solved
2024-08-23 13:02:53 +00:00
overlookmotel
d304d6f973
refactor(semantic)!: always create a scope for CatchClause ( #5109 )
...
Part of #5008 . Make scope for `CatchClause` unconditional. i.e. always create a scope, even if there is no catch parameter.
2024-08-23 08:30:27 +00:00
overlookmotel
91343913ca
fix(semantic): transform checker check unresolved references ( #5096 )
...
Transform checker check root unresolved references.
The transform checker is now checking pretty much everything it can.
Only fields of `ScopeTree` and `SymbolTable` that it's *not* checking are those which contain `AstNodeId`s, because transformer does not create node IDs at present:
* `ScopeTree::node_ids`
* `SymbolTable::declarations`
* `Reference::node_id`
Checking also only proceeds in "from AST" direction.
i.e. for each `SymbolId` which appears in the AST, we check everything about that symbol. But we *don't* go through all the "rows" in `SymbolTable` and check if there are any extra symbols in the table which aren't in the AST.
Presumably transformer will leave a lot of old symbols lying around in `SymbolTable` (ditto scopes and references). We'd need to add `ScopeFlags::Deleted`, `SymbolFlags::Deleted` and `ReferenceFlags::Deleted` for the transformer to be able to "delete" existing symbols.
2024-08-23 07:52:30 +00:00
overlookmotel
c57e078c71
fix(semantic): transform checker check unbound references ( #5093 )
2024-08-23 08:37:48 +01:00
Boshen
aa7718ab7b
feat(transform_conformance): show printed output alongside with errors ( #5105 )
...
closes #5098
```
cargo run -p oxc_transform_conformance -- --filter logical-assignment/arrow-functions-transform/input.js
Input:
var a;
a ||= () => {};
a &&= () => {};
a ??= () => {};
Expected:
var a;
a || (a = () => {});
a && (a = () => {});
a ?? (a = () => {});
Transformed:
var a;
a || (a = () => {});
a && (a = () => {});
a ?? (a = () => {});
Errors:
x Symbol reference IDs mismatch:
| after transform: SymbolId(0): [ReferenceId(0), ReferenceId(1),
| ReferenceId(2), ReferenceId(3), ReferenceId(4), ReferenceId(5),
| ReferenceId(6), ReferenceId(7), ReferenceId(8)]
| rebuilt : SymbolId(0): [ReferenceId(0), ReferenceId(1),
| ReferenceId(2), ReferenceId(3), ReferenceId(4), ReferenceId(5)]
x Reference flags mismatch:
| after transform: ReferenceId(4): ReferenceFlags(Write)
| rebuilt : ReferenceId(1): ReferenceFlags(Read | Write)
x Reference flags mismatch:
| after transform: ReferenceId(6): ReferenceFlags(Write)
| rebuilt : ReferenceId(3): ReferenceFlags(Read | Write)
x Reference flags mismatch:
| after transform: ReferenceId(8): ReferenceFlags(Write)
| rebuilt : ReferenceId(5): ReferenceFlags(Read | Write)
Passed: true
```
2024-08-23 04:00:45 +00:00
overlookmotel
d5de97d6fe
fix(semantic): transform checker check reference flags ( #5092 )
2024-08-23 00:21:21 +00:00
overlookmotel
9da6a21e40
refactor(semantic): rename transform checker output for reference symbol mismatches ( #5091 )
2024-08-22 23:40:27 +00:00
overlookmotel
a8005b9914
fix(semantic): transform checker check symbol redeclarations ( #5089 )
2024-08-22 23:40:26 +00:00
overlookmotel
205bff7ea9
fix(semantic): transform checker check symbol references ( #5088 )
2024-08-22 23:40:25 +00:00
overlookmotel
4a57086d79
fix(semantic): transform checker check symbol IDs ( #5078 )
2024-08-22 15:08:48 +00:00
overlookmotel
ea7d2163e3
fix(semantic): transform checker check symbol spans ( #5076 )
2024-08-22 15:08:47 +00:00
overlookmotel
1b6b27a6de
fix(semantic): transform checker check symbol flags ( #5074 )
2024-08-22 15:08:45 +00:00
Dunqing
3b353321ad
fix(transformer/logical-assignment-operators): fix semantic errors ( #5047 )
...
Fix semantic error caused by `clone_in` causing `reference_id` to not exist.
In this PR, I try to use `move_expression` as much as possible instead of `expr.clone_in`. But in some cases, we need to reuse the same expression in multiple places. I have added a `clone_expression` to workaround it
I felt a bit painful we missing a [clone_in_scope](https://github.com/oxc-project/oxc/issues/4804 ) API
2024-08-22 08:41:31 +00:00
overlookmotel
f187b71877
fix(semantic): transform checker compare scope children ( #5056 )
2024-08-22 02:34:44 +00:00
overlookmotel
b52c6a4269
fix(semantic): transform checker compare scope parents ( #5055 )
2024-08-22 02:34:43 +00:00
overlookmotel
da64014a6c
fix(semantic): transform checker catch more scope flags mismatches ( #5054 )
...
There was a bug previously where scope flags were only checked if there was also a bindings mismatch.
2024-08-22 02:34:43 +00:00
overlookmotel
67d1a96391
fix(semantic): transform checker compare scope flags ( #5052 )
2024-08-22 02:34:41 +00:00
overlookmotel
ee7ac8b0b7
refactor(semantic): store all data in PostTransformChecker in transform checker ( #5050 )
...
Pure refactor of transform checker. Store all scope data in `PostTransformChecker` so it doesn't need to be passed around. `SemanticData` contains a full set of all semantic data for semantic pass, so we have 2 instances of it for 1. after transform and 2. rebuilt semantic.
2024-08-21 17:04:48 +00:00
overlookmotel
8cded08eb8
refactor(semantic): rename error labels in transformer checker snapshots ( #5044 )
...
Rename labels in transformer checker snapshots "after transform" vs "rebuilt".
2024-08-21 14:33:19 +00:00
overlookmotel
863b9cb921
fix(semantic): transform checker handle conditional scopes ( #5040 )
...
Some scopes are conditional e.g. `ForStatement` only gets a scope when initializer has a binding (`for (let i = 0; ...)` vs `for (i = 0; ...)`).
Make transform compare this between post-transform and fresh semantics.
2024-08-21 12:07:14 +00:00
overlookmotel
586e15c814
refactor(semantic): reformat transform checker errors ( #5039 )
...
Reformat transform checker error output - shorter and consistent capitalization.
2024-08-21 12:07:11 +00:00
Boshen
1bd9365bd0
fix(coverage): correctly check semantic data after transform ( #5035 )
...
closes #4999
2024-08-21 09:35:04 +00:00
Dunqing
f51d3f9169
feat(transformer/nullish-coalescing-operator): handles nullish coalescing expression in the FormalParamter ( #4975 )
...
### What I did in this PR
1. Replace `self.clone_identifier_reference` with `ctx.clone_identifier.reference`
2. Remove the usage of `ast.copy`
3. Handle below example correctly
### Example
```js
// Input
var foo = object.foo ?? "default";
// Output
var _object$foo;
var foo =
(_object$foo = object.foo) !== null && _object$foo !== void 0
? _object$foo
: "default";
```
2024-08-20 01:06:37 +00:00
Dunqing
f794870dd4
feat(transformer/nullish-coalescing-operator): generate the correct binding name ( #4974 )
...
match Babel's [implementation](440fe41333/packages/babel-plugin-transform-nullish-coalescing-operator/src/index.ts (L40) )
2024-08-20 01:06:36 +00:00
Boshen
64ace42566
feat(transform_conformance): show transform conformance errors ( #4976 )
2024-08-19 09:01:34 +00:00
Boshen
4fdf26dac8
refactor(transform_conformance): add driver ( #4969 )
2024-08-19 07:27:39 +00:00
Dunqing
f1fcdde593
feat(transformer): support react fast refresh ( #4587 )
...
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..
2024-08-15 16:41:30 +00:00
Dunqing
0d7912217a
feat(transformer): support logical-assignment-operators plugin ( #4890 )
...
part of #4754
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865 .
2024-08-15 10:10:36 +00:00
Dunqing
ab1d08ccfb
feat(transformer): support optional-catch-binding plugin ( #4885 )
...
part of #4754
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865 .
2024-08-15 10:10:34 +00:00
Dunqing
69da9fda3a
feat(transformer): support nullish-coalescing-operator plugin ( #4884 )
...
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865 .
2024-08-15 10:10:33 +00:00
Dunqing
3a66e5843d
feat(transformer): support exponentiation operator plugin ( #4876 )
...
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865 .
2024-08-15 10:10:32 +00:00
Dunqing
62f759c1f2
fix(transformer/typescript): generated assignment for constructor arguments with access modifiers should be injected to the top of the constructor ( #4808 )
...
fix : #4789
2024-08-10 11:21:45 +00:00
Dunqing
3987665490
fix(transformer/typescript): incorrect enum-related symbol_id/reference_id ( #4660 )
...
part of #4581
2024-08-06 02:57:19 +00:00
Dunqing
03c643a8af
fix(semantic): incorrect scope_id for catch parameter symbols ( #4659 )
...
When we move all the bindings in the CatchClause scope to its child scope (BlockStatement), we also need to replace the scope_id in the symbol with the scope_id of the new scope.
2024-08-06 02:57:18 +00:00
Dunqing
5327acdc1f
fix(transformer/react): the require IdentifierReference does not have a reference_id ( #4658 )
...
part of #4581 . Looks we had to pass `TraverseCtx` to the `ModuleImports`
2024-08-05 22:55:07 +00:00
Dunqing
48031ada93
fix(transformer/typescript) shadowed imports have not been removed ( #4550 )
...
close : #4423
2024-08-05 03:15:14 +00:00
Dunqing
4efd54b84d
fix(transformer/typescript): incorrect SymbolFlags for jsx imports ( #4549 )
...
All `SymbolFlags` for imports should be `SymbolFlags::Import`
2024-08-05 03:15:13 +00:00
Dunqing
3a6e4d91cf
feat(transformer_conformance): test ScopeTree and SymbolTable for correctness after transformation ( #4581 )
...
part of #4549
This test verifies that the correct symbols and scopes were added/changed during the transformation. From the snapshots, most of them are incorrect currently
2024-08-04 11:45:10 +00:00
Dunqing
ecdee88cfb
fix(transformer/typescript): incorrect eliminate exports when the referenced symbol is both value and type ( #4507 )
2024-07-27 12:11:29 -04:00
Dunqing
f8565ae3cd
fix(transformer/typescript): unexpectedly removed class binding from ExportNamedDeclaration ( #4351 )
...
The original `SymbolFlags` methods were a bit confusing I renamed and re-implemented them.
2024-07-18 16:44:38 +00:00
Dunqing
a88d588a07
feat(semantic): add ReferenceFlags::TSTypeQuery to indicate referenced by TSTypeQuery ( #4317 )
...
`ReferenceFlags::TSTypeQuery` can be used to help us insist on whether the reference is referenced by the type or not.
2024-07-17 09:52:57 +00:00
Dunqing
c362bf7edf
fix(semantic): incorrect resolve references for TSInterfaceHeritage ( #4311 )
...
related issue: https://github.com/oxc-project/oxc/issues/3963
fixes: https://github.com/oxc-project/monitor-oxc/actions/runs/9960183591/job/27518854841
2024-07-17 03:33:02 +00:00
Dunqing
351ecf2707
fix(semantic): incorrect resolve references for TSTypeQuery ( #4310 )
...
```ts
type A = typeof Foo
^^^ Only allow reference to value symbol
```
I have verified the changed snapshot. That's correct
2024-07-17 03:33:00 +00:00
Boshen
83bd40db4e
chore: turn off doctest for all [[bin]]
2024-07-14 16:55:19 +08:00
Boshen
e167ef79c6
fix(codegen): print parenthesis properly ( #4245 )
...
`TSParenthesizedType` handles parenthesis in ts types.
It should be considered a bug if parenthesis is not printed correctly after this PR.
2024-07-14 04:13:10 +00:00
Don Isaac
4413e2d298
fix(transformer): missing initializer for readonly consructor properties ( #4103 )
2024-07-08 12:45:50 +08:00
Boshen
aaac2d8775
fix(codegen): preserve parentheses from AST instead calculating from operator precedence ( #4055 )
...
…operator precedence
Calculating from operator precedence is currently unsafe and will result
incorrect semantics.
2024-07-05 14:01:17 +08:00
Dunqing
bdee156c5d
fix(transformer/typescript): declare class incorrectly preserved as runtime class ( #3997 )
...
fix : #3993
2024-07-01 16:04:40 +00:00
Dunqing
a50ce3d299
fix(transformer/typescript): missing initializer for class constructor arguments with private and protected modifier ( #3996 )
...
close : #3992
2024-07-01 15:10:32 +00:00
Boshen
5845057bff
refactor(transformer): pass in symbols and scopes ( #3978 )
...
This PR adds a new method `build_with_symbols_and_scopes` to make semantic building optional, there may be prior steps that has the semantic data already built.
2024-06-30 06:33:48 +00:00
DonIsaac
63f36daae0
feat(parser): parse modifiers with parse_modifiers (take 2) ( #3977 )
...
Same as #3948 , with fixes for bugs found by @Boshen.
2024-06-30 03:46:34 +00:00
Boshen
14bc31ee74
Revert "feat(parser): parse modifiers with parse_modifiers ( #3948 )"
...
This reverts commit 7b38bde073 .
2024-06-29 14:16:26 +08:00
DonIsaac
7b38bde073
feat(parser): parse modifiers with parse_modifiers ( #3948 )
...
Closes #3929
2024-06-29 05:29:47 +00:00
Dunqing
5501d5ce33
feat(transformer/typescript): transform import {} from "mod" to import "mod" ( #3866 )
...
close : #3736
2024-06-24 03:27:39 +00:00
Boshen
445603444f
feat(ast)!: add IdentifierReference to ExportSpecifier ( #3820 )
...
closes #3795
closes #3796
2024-06-22 11:43:41 +00:00
Boshen
2a16ce0624
feat(traverse): disable syntax check and disable build module record ( #3794 )
...
These can be skipped because :
* semantic errors are not passed to the caller
* module record is not used
2024-06-20 13:05:35 +00:00
Dunqing
497769cb60
feat(ast): add some visitor functions ( #3785 )
2024-06-20 05:23:04 +00:00
Boshen
4e9d8a5585
chore: fix some nightly clippy warnings
2024-06-19 00:53:58 +08:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt
2024-06-19 00:48:30 +08:00
Boshen
5c38a0fd69
feat(codegen)!: new code gen API ( #3740 )
...
This PR introduces two type alias to avoid the confusing const generic `pub struct Codegen<'a, const MINIFY: bool>`
* CodeGenerator - Code generator without whitespace removal.
* WhitespaceRemover - Code generator with whitespace removal.
Usage is changed to a builder pattern:
```rust
CodeGenerator::new()
.enable_comment(...)
.enable_sourcemap(...)
.build(&program);
```
2024-06-18 15:50:12 +00:00
Boshen
5a99d30eba
feat(codegen): improve codegen formatting ( #3735 )
2024-06-18 11:10:36 +00:00
Boshen
982e6f08df
chore: make println and eprintln opt-in ( #3712 )
...
I noticed accidental `println` can be merged, which isn't really nice.
2024-06-17 10:40:34 +00:00
Boshen
534242a729
feat(codegen)!: remove CodegenOptions::enable_typescript ( #3674 )
...
The typescript transform pass is now required to strip typescript syntax
for codegen to print things properly.
Codegen will now print whatever is in the AST.
2024-06-14 21:56:00 +08:00
Dunqing
59666e0127
fix(transformer): do not rename accessible identifier references ( #3623 )
...
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`
2024-06-13 15:26:38 +08:00
Boshen
c041e9d1a9
chore: bump test262, babel and TypeScript submodules ( #3644 )
2024-06-12 18:42:32 +08:00
Boshen
b58d8eb88f
fix!(codegen): remove the unecessary 4th argument from Codegen::new ( #3640 )
2024-06-12 07:58:54 +00:00
Boshen
d77ec9f95a
chore: remove trailing whitespaces for all files; add .editorconfig ( #3639 )
2024-06-12 15:47:26 +08:00
Boshen
f6752b482f
feat!(ast): make Trivias clonable by adding Arc ( #3638 )
...
This makes `Trivias` cloneable and stops us from using `Rc::new` and
`Rc::clone` everywhere.
`Trivias` is rarely cloned so an `Arc` should suffice.
2024-06-12 13:16:10 +08:00
Dunqing
5793ff1986
refactor(transformer): replace &’a Trivias with Rc<Trivias> ( #3580 )
...
`Transformer` needs to borrow `Trivias`.
8be1cc8052 (r1630711060)
2024-06-11 13:23:41 +08:00
Dunqing
e8a20f8d50
feat(transformer/typescript): remove typescript ast nodes ( #3559 )
...
According to Babel tests feedback, remove some known ts AST nodes.
There are still many TS AST nodes that need to be deleted
2024-06-07 05:04:22 +00:00
Dunqing
0007ee47be
chore(coverage, transformer_conformance): print all AST whether or not they are Typecript AST ( #3556 )
...
We have a conclusion that codegen will print whatever is in the AST,
instead of having an option to enable printing TypeScript syntax. I plan
to remove codegen's `enable_typescript` option after we strip out all
typescript AST in the transformer typescript plugin.
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-06 15:45:20 +08:00
overlookmotel
837776e1ab
fix(transformer): TS namespace transform do not track var decl names ( #3501 )
...
Don't track variable declaration or import binding names in TS namespace transform.
Babel does, but it appears to be wrong. It's illegal to have a `var`/`let`/`const` declaration or import in same scope as a TS namespace declaration with same binding.
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAQTgMyhEcDkUCmBDAYxkwG4AoAOzxBwGcxCdE4BvAXzLIIgtvgCE4AXjgBGclRr1GcQSzJxFcADY54AD3Icyq+AGFhYidToMCTA-KUq1cTWW0A3PFDgARQ+Monp596wUlXTstMiA
2024-06-03 12:35:57 +00:00
overlookmotel
8e4f33557d
fix(transformer): output empty file for TS definition files ( #3500 )
...
As discussed in
https://github.com/oxc-project/oxc/pull/3489#issuecomment-2143482458 ,
transformer should output an empty file for TS definition files.
2024-06-03 20:25:02 +08:00
IWANABETHATGUY
0cdb45a1ff
feat(oxc_codegen): preserve annotate comment ( #3465 )
...
1. Copy tests from
efa3dd2d8e/internal/bundler_tests/bundler_dce_test.go (L3833-L3971)
2. Add option to preserve annotate comment like `/* #__NO_SIDE_EFFECTS__
*/` and `/* #__PURE__ */`
2024-05-30 15:25:23 +08:00
Dunqing
b4fd1ad31c
fix(transformer/typescript): variable declarations are not created when a function has a binding with the same name ( #3460 )
2024-05-29 23:00:22 +00:00
Dunqing
1a50b86281
refactor(typescript/namespace): reuse TSModuleBlock's scope id ( #3459 )
2024-05-29 23:00:15 +00:00
overlookmotel
90b0f6da81
fix(transformer): use UIDs for React imports ( #3431 )
...
Use UIDs for local var names for React JSX imports e.g. `_jsx` in
`import { jsx as _jsx } from "react/jsx-runtime";`.
2024-05-29 18:32:10 +08:00
Dunqing
6a1f2c21df
chore(transform_conformance): skip some test cases ( #3449 )
2024-05-28 13:38:03 +00:00
Dunqing
92df98b005
feat(transformer/typescript): report error that do not allow namespaces ( #3448 )
2024-05-28 13:38:01 +00:00
Dunqing
a6b073a47c
feat(transformer/typescript): report error for namespace exporting non-const ( #3447 )
2024-05-28 13:38:00 +00:00
Dunqing
150255c704
feat(transformer/typescript): if within a block scope, use let to declare enum name ( #3446 )
2024-05-28 13:37:58 +00:00
Dunqing
e80552c797
feat(transformer/typescript): if binding exists, variable declarations are not created for namespace name ( #3445 )
2024-05-28 13:37:57 +00:00
Dunqing
816a782254
feat(transformer): support targets option of preset-env ( #3371 )
...
The implementation of the `targets` options was copied from
[swc](https://github.com/swc-project/swc/tree/main/crates/preset_env_base ),
which resulted in some added dependencies in transformer.
Currently, it has supported enabling plugins by `targets`
2024-05-27 10:33:40 +08:00
Dunqing
241e8d1899
feat(transformer/typescript): if the binding exists, the identifier reference is not renamed ( #3387 )
...
Related:
https://github.com/oxc-project/oxc/discussions/3251#discussioncomment-9528247
2024-05-27 01:00:04 +00:00
overlookmotel
d4371e8f95
fix(transformer): use UIDs in TS namespace transforms ( #3395 )
...
Use the `TraverseCtx::generate_uid` method introduced in #3395 to fix
some of the TS namespace test cases.
But... I honestly have no idea what I'm doing here!
I am running up against a combination of 3 different areas where I know
very little:
1. I am unfamiliar with `Semantic`.
2. I am unfamiliar with Oxc's conventions for writing transforms.
3. I don't "speak" Typescript!
This PR should not be merged as is. I'm pretty sure it's wrong. I've
done it mostly just to test out `generate_uid`.
In particular:
1. Is `SymbolFlags::FunctionScopedVariable` the right flags to use in
all cases here?
2. `generate_uid` creates a symbol, and registers a binding for it in
the scope tree. So if there are any branches in this logic where `name`
doesn't actually get used after `generate_uid` is called, then it's not
right.
3. Identifiers which are added to AST should also have corresponding
`ReferenceId`s created for them (but I imagine this is also missing in
many other places in the transformer).
On point 2: We could split up `generate_uid` into 2 functions. One
function would find a valid UID name *but not register a binding for
it*. If you want to actually use that name, you'd call a 2nd function to
generate the binding. Would that be a better API?
Could someone help me out to progress this please?
(Sorry my lack of knowledge is a bit useless here. I will learn all
these things in time, but just trying to be honest about where I'm at
right now. I'm sure I could figure it out myself, but it would take me
hours, whereas others will probably look at it and know what to do in
about 5 mins.)
2024-05-27 08:53:13 +08:00
mysteryven
d7849f8865
refactor(linter): find return statement by using CFG in react/require-render-return ( #3353 )
...
Maybe currently Class components are relatively few in quantity, didn't performance changed.
2024-05-19 14:59:12 +00:00
Dunqing
e2c6fe0cb1
feat(transformer): report errors when options have unknown fields ( #3322 )
2024-05-19 01:19:40 +08:00
Dunqing
9ee962add8
feat(transformer): support from_babel_options in TransformOptions ( #3301 )
...
Move `BabelOptions` to Transformer. The `output.json` is a standard babel configuration. We can reuse BabelOptions to read [babel.config.json](https://babeljs.io/docs/configuration#babelconfigjson ) or our configuration(maybe oxc.config.json)
The current `from_babel_options` implementation is copied from the `transform_options` in `test_case.rs`, which I'll completely reimplement next
2024-05-16 10:10:39 +00:00
Dunqing
8ff1ffba74
feat(transformer_conformance): skip some tests that are known to fail ( #3293 )
...
I don't think we need to be completely consistent with Babel's output.
Because Babel's output doesn't always make sense.
2024-05-15 22:06:00 +08:00
Dunqing
b9d69ad665
feat(transformer): do not add self attribute in react/jsx plugin ( #3287 )
...
follow-up: https://github.com/oxc-project/oxc/pull/3258 .
2024-05-15 17:59:57 +08:00
Dunqing
b4fa27a2ee
fix(transformer): do no add __self when the jsx is inside constructor ( #3258 )
2024-05-14 16:12:49 +01:00
Boshen
530455849b
chore(tasks): add commit sha to snapshots to make sure submodules are not outdated ( #3267 )
...
If submodules are outdated, it'll panic with the following message
```
Repository is outdated, please run `just submodules` to update it.
```
For us maintainers, we'll need the env `UPDATE_SNAPSHOT` to force an update.
2024-05-14 10:18:00 +00:00
Dunqing
eefb66f750
feat(ast): add type to AccessorProperty to support TSAbractAccessorProperty ( #3256 )
2024-05-13 12:35:58 +00:00
Dunqing
34dd53cc98
feat(transformer): report ambient module cannot be nested error ( #3253 )
2024-05-13 07:51:06 +00:00
Boshen
dbde5b3a04
refactor(diagnostics): remove export of miette
2024-05-12 11:46:48 +08:00
Boshen
09f34fc942
refactor(semantic): unify diagnostic in checker
2024-05-12 01:07:28 +08:00
Boshen
7067f9c646
refactor(transformer): clean up more diagnostics
2024-05-12 00:57:58 +08:00
Dunqing
1b29e63300
feat(transformer): do not elide jsx imports if a jsx element appears somewhere ( #3237 )
2024-05-11 15:00:26 +00:00
Dunqing
fd6a1aa1d2
feat(transformer_conformance): correct source type ( #3233 )
2024-05-11 09:30:43 +00:00
Dunqing
6ac8a8479e
fix(transformer): correctly jsx-self inside arrow-function ( #3224 )
2024-05-11 00:48:18 +00:00
Dunqing
18d853bb2b
feat(transformer/react): support development mode ( #3143 )
2024-05-10 22:07:33 +08:00
Dunqing
0ba7778e5e
fix(parser): correctly parse cls.fn<C> = x ( #3208 )
...
close : #3206
2024-05-09 10:23:45 +08:00
overlookmotel
9590eb0cf4
fix(transform): implement transform-react-display-name with bottom-up lookup ( #3183 )
...
Sliced off from #3152 .
Re-implement `transform-react-display-name` using bottom-up lookup
provided by `Traverse` trait.
This fixes the 1 remaining failing test case for this plugin (see
#2937 ).
`Traverse` is not complete yet (see #3182 ), so this is also not ready to
merge yet.
2024-05-08 15:33:39 +00:00
Dunqing
a227050ed0
chore: update babel repo ( #3205 )
2024-05-08 20:15:15 +08:00
Boshen
a63a45d5b2
refactor(transformer): remove the requirement of Semantic ( #3140 )
...
It seems like we need to rebuild the scopes and symbols while
traversing. We can't utilize the scopes and symbols built by semantic
because they are immutable.
2024-04-30 12:48:21 +08:00
Boshen
d76507699d
chore(transform_conformance): skip transform-destructuring ( #3136 )
2024-04-30 00:09:22 +08:00
Boshen
5a3f8a5811
feat(transform_conformance): handle parse error ( #3135 )
2024-04-30 00:07:53 +08:00
Dunqing
b5894964d1
fix(transformer/arrow-functions): should not transform this in class ( #3129 )
2024-04-29 13:44:10 +00:00
Dunqing
843318cdbe
refactor(transformer/typescript): reimplementation of Enum conversion based on Babel ( #3102 )
...
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>
2024-04-29 16:26:22 +08:00
Dunqing
905ee3fef1
feat(transformer): add arrow-functions plugin ( #3083 )
...
close : #2983
2024-04-29 08:04:01 +00:00
Dunqing
c3d8a85eb5
feat(semantic): report that enum member must have initializer ( #3113 )
...
See
https://www.typescriptlang.org/play/?target=99#code/KYOwrgtgBAglDeAoKKoEMoF4oFk0BcALAOgGcBLEACgEYBKAGmVQCMmBfRRUSKAIQTMUGbACIaAJgDMopqihtEnRABtg+KADMwIAMZYoVOlgB8USVIDc3cNADCg+SK07dRuaw6IgA
2024-04-27 22:08:02 +08:00
Boshen
78875b79fe
feat(transformer): implement typescript namespace ( #3025 )
...
Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-04-25 10:26:11 +00:00
Dunqing
3831147b6d
feat(transformer/typescript): report error for export = <value> ( #3021 )
2024-04-18 18:56:29 +08:00
Dunqing
7416de217b
feat(transformer/typescript): reports error for import lib = require(...); ( #3020 )
2024-04-18 18:54:45 +08:00
Dunqing
e14ac17c72
feat(transformer/typescript): insert this assignment after the super call ( #3018 )
2024-04-18 18:53:01 +08:00
Boshen
722d4c2350
fix(transformer): TypeScriptOptions deserialize should fallback to default ( #3012 )
2024-04-17 16:27:50 +08:00
Dunqing
b72bdcaf96
feat(transformer/react): reports duplicate __self/__source prop error ( #3009 )
2024-04-17 13:34:31 +08:00
Boshen
df1996157f
chore(transform_conformance): ignore more unsupported plugins ( #3008 )
2024-04-16 18:59:21 +08:00
Dunqing
cdd3bc5a4e
feat(transformer_conformance): enable typescript when the typescript plugin is present ( #3007 )
2024-04-16 10:47:06 +00:00
Dunqing
99e038cfc0
fix(transformer/typescript): modifiers should not be removed ( #3005 )
...
`codegen` relies on the modifier to decide whether to print or not. For
example, if declare is present, nothing will be printed if typescript is
not enabled.
We may need to solve this problem in a way that doesn't rely on
modifers.
2024-04-16 10:33:13 +00:00
Boshen
ae9d681b4d
feat(transform_conformance): skip windows tests ( #3003 )
2024-04-16 17:50:43 +08:00
Boshen
85a3653994
feat(transformer): add "_jsxFileName" variable in jsx source plugin ( #3000 )
2024-04-16 17:40:24 +08:00
Boshen
67045467c7
fix(transformer): react development default value should be false ( #3002 )
2024-04-16 17:28:31 +08:00
Boshen
5f4c1e1d3e
chore(transform_conformance): skip custom presets ( #3001 )
2024-04-16 17:21:34 +08:00
Dunqing
afb1dd4b24
feat(transformer/typescript): support for transform TSImportEqualsDeclaration ( #2998 )
2024-04-16 06:45:41 +00:00
Dunqing
6732e8b9af
feat(transformer/typescript): support for transform enum ( #2997 )
...
The current implementation is copied from the previous implementation
2024-04-16 14:39:37 +08:00
Boshen
e43c245388
feat(transformer): add import helpers to manage module imports ( #2996 )
...
closes #2971
2024-04-16 14:33:44 +08:00
Dunqing
6a53fa367b
feat(transformer/typescript): correct elide imports/exports statements ( #2995 )
...
remove ts annotations one benefit: `IdentifierReference` only used on js
code
The `TypescriptReferenceCollector` implementation is inspired by
5f75019683/crates/swc_ecma_transforms_typescript/src/strip_import_export.rs (L9-L99)
This seems simpler to implement than using scope
2024-04-16 11:06:58 +08:00
Boshen
82e00bc951
refactor(transformer): remove boilerplate code around decorators to reduce noise ( #2991 )
2024-04-15 13:51:09 +08:00
Boshen
b4bfa2f34c
refactor(transform_conformance): correctly handle BABEL_8_BREAKING ( #2990 )
2024-04-15 13:41:45 +08:00
Boshen
5a286c3d9f
feat(transform_conformance): drop more unsupported plugins ( #2984 )
2024-04-14 23:04:04 +08:00
Boshen
9643cba4a4
feat(transform_conformance): drop all babel 7 specific tests ( #2982 )
...
@Dunqing Is this correct?
2024-04-14 23:02:38 +08:00
Boshen
c753c9fa74
feat(transform_conformance): handle deserialization errors ( #2980 )
2024-04-14 22:47:28 +08:00
Boshen
b6b63ac9bc
feat(transform_conformance): skip tests with plugin.js ( #2978 )
2024-04-14 21:55:32 +08:00
Boshen
7cf0927a38
feat(transform_conformance): skip tests with plugin.js ( #2977 )
2024-04-14 21:45:27 +08:00
Boshen
c211f1e57f
feat(transformer): add diagnostics to react transform ( #2974 )
2024-04-14 21:42:32 +08:00
Boshen
ef602af4cc
feat(transform_conformance): skip plugins we don't support yet ( #2967 )
2024-04-14 21:32:03 +08:00
Boshen
c7e70c80f0
fix(transformer): deserialize ReactJsxRuntime with camelCase ( #2972 )
2024-04-14 19:40:24 +08:00
Boshen
3a6eae1abd
feat(transformer): apply jsx self and source plugin inside jsx transform ( #2966 )
2024-04-14 19:10:59 +08:00
Boshen
10814d5331
fix(transformer): turn on react preset by default ( #2968 )
2024-04-14 19:04:59 +08:00
Boshen
35e3b0f1cb
fix(transformer): fix incorrect jsx whitespace text handling ( #2969 )
2024-04-14 18:40:40 +08:00
Boshen
bd9fc6d169
feat(transformer): react jsx transform ( #2961 )
2024-04-14 10:50:17 +08:00
Boshen
6561392202
feat(transform_conformance): add baseline for all TypeScript and jsx plugins
2024-04-13 19:05:39 +08:00
Miles Johnson
e67355045e
feat(transformer): start on TypeScript annotation removal ( #2951 )
2024-04-13 18:49:54 +08:00
Boshen
e651e50bda
feat(transformer): add the most basic plugin toggles ( #2950 )
2024-04-12 20:25:34 +08:00
Boshen
60ccbb105c
refactor(transformer): clean up some code ( #2949 )
2024-04-12 20:23:44 +08:00
Boshen
14754777a4
feat(transformer): implement react-jsx-source ( #2948 )
2024-04-12 20:21:54 +08:00
Boshen
f903a225a8
feat(transformer): implement react-jsx-self ( #2946 )
2024-04-12 18:08:36 +08:00
Boshen
0c04bf743f
feat(transformer): transform TypeScript namespace ( #2942 )
2024-04-12 10:19:13 +08:00
Boshen
f3a28c61b9
chore(transform_conformance): enable typescript plugin snapshot
2024-04-11 20:06:53 +08:00
Boshen
3419306ac0
feat(transformer): add filename ( #2941 )
2024-04-11 18:43:51 +08:00
Boshen
02adc76760
feat(transformer): implement plugin-transform-react-display-name top-down ( #2937 )
...
Missing case:
https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/nested/input.js
```js
var foo = qux(createReactClass({}));
var bar = qux(React.createClass({}));
```
This requires recursing down.
Top-down implementation in swc:
67ec5e09b9/crates/swc_ecma_transforms_react/src/display_name/mod.rs (L108-L132)
Or bottom-up in babel:
08b0472069/packages/babel-plugin-transform-react-display-name/src/index.ts (L87-L98)
2024-04-11 15:32:32 +08:00
Boshen
07bd85e25d
chore(transform_conformance): clear the conformance snapshot
2024-04-11 14:09:59 +08:00
Boshen
d65eab3b8b
feat(transformer): add react preset ( #2921 )
2024-04-09 12:39:33 +08:00
Boshen
7710d8caf1
feat(transformer): add compiler assumptions ( #2872 )
...
closes #2869
2024-03-31 02:04:21 +00:00
Boshen
7034bcc47d
feat(transformer): add proposal-decorators ( #2868 )
2024-03-30 21:07:36 +08:00
Boshen
ffadcb08d9
feat(transformer): add react plugins ( #2867 )
2024-03-30 20:56:10 +08:00
Boshen
293b9f482a
feat(transformer): add transform-typescript boilerplate ( #2866 )
2024-03-30 20:48:35 +08:00
Boshen
c1a2958a5a
chore: remove oxc_transformer for a reimplementation ( #2865 )
...
closes #2860
2024-03-30 17:19:46 +08:00
Dunqing
ec05a41525
chore: update transformer snapshots ( #2838 )
2024-03-27 15:02:09 +08:00
Dunqing
d67100730b
feat(tasks/transforme_conformance): support for testing oxc's test cases ( #2835 )
...
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
```
2024-03-27 14:14:15 +08:00
Ali Rezvani
243131d7a4
feat(transformer): numeric separator plugin. ( #2795 )
...
[es2021 numeric
separator](https://babeljs.io/docs/babel-plugin-transform-numeric-separator )
2024-03-26 18:15:12 +08:00
Ali Rezvani
56493bd02b
feat(transformer): add transform literal for numeric literals. ( #2797 )
...
[es2015 transform
literals](https://babeljs.io/docs/babel-plugin-transform-literals )
---------
Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-03-26 16:27:32 +08:00
Dunqing
220f722f19
chore: update snapshots ( #2817 )
...
Babel repo is updated in #2813 and #2814
2024-03-26 11:53:26 +08:00
Dunqing
68e011c479
fix(tasks/transform-conformance) when the output file does not exist, the output content should be empty ( #2808 )
...
https://github.com/oxc-project/oxc/pull/2795#issuecomment-2018018675
2024-03-25 23:28:00 +08:00
underfin
d9b77d853b
refactor(sourcemap): change sourcemap name to take a reference ( #2779 )
2024-03-23 21:40:05 +08:00
Dunqing
7a12514151
fix(transformer/decorators): missing check private function ( #2607 )
2024-03-05 11:37:00 +08:00
Boshen
ef932a3c27
refactor(codegen): clean up API around building sourcemaps ( #2602 )
...
closes #2564
2024-03-04 16:03:33 +08:00
Dunqing
6d43e851e8
feat(transformer/typescript): support transform constructor method ( #2551 )
2024-03-01 21:12:30 +08:00
Dunqing
25e03cb0ef
feat(tasks/transformer): enable typescript when the typescript plugin is provided ( #2548 )
...
Babel has many test cases that are js files, but in ts syntax.
2024-03-01 21:04:55 +08:00
Dunqing
f760108094
feat(transformer): call build module record ( #2529 )
2024-02-28 14:35:35 +08:00
Dunqing
cd75c1ca59
feat(transformer/decorators): insert only one private in expression ( #2486 )
2024-02-26 15:48:47 +08:00
Dunqing
3d008abacb
feat(transformer/decorators): insert instanceBrand function ( #2480 )
2024-02-23 23:04:27 +08:00
Dunqing
2628c97eda
feat(transformer/decorators): transform getter function ( #2473 )
2024-02-23 10:11:45 +08:00
Andrew McClenaghan
e6d536cb9b
feat(codegen): configurable typescript codegen ( #2443 )
...
- Adds option to `CodegenOptions` - `enable_typescript` to enable output
of TS.
- Stops skipping output that is TS when `enable_typescript` is enabled
- Adds TS support to
- Function
- FormalParameter
- BindingPattern
- Adds basic tests for TS generation
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-20 12:09:28 +08:00
Dunqing
27b2c212c4
refactor(transformer/decorators): if it is a private method definition, transform it ( #2427 )
2024-02-19 19:17:11 +08:00
Boshen
70a0076eed
refactor: remove global allocator from non-user facing apps ( #2401 )
...
The runtime performance gains does not out weight the compilation speed from
building the custom allocators, which takes about a minute to build on
slower machines.
2024-02-12 14:09:05 +08:00
Dunqing
8e221cb26e
fix(transformer): update snapshot ( #2268 )
2024-02-02 17:00:44 +08:00
Boshen
650f6c942f
refactor: use our forked version of miette::Reporter for tests ( #2266 )
2024-02-02 16:15:31 +08:00
Dunqing
02c18d8506
feat(transformer/decorators): support for static and private member decorators ( #2246 )
2024-02-01 15:19:14 +08:00
Dunqing
ba85b097e0
feat(transformer/decorators): support method decorator and is not static ( #2238 )
2024-02-01 11:36:22 +08:00
Dunqing
a79988d5e2
feat(transformer/decorators): support static member ( #2235 )
2024-01-31 19:11:27 +08:00
Dunqing
3b85e1813b
feat(transformer/decorators): ensure property key consistency ( #2233 )
2024-01-31 19:05:52 +08:00
Dunqing
e5719e9b4d
feat(transformer/decorators): support transform member decorators ( #2171 )
2024-01-26 10:14:19 +08:00
Boshen
889837704c
feat(semantic): cfg prototype ( #2019 )
...
Co-authored-by: U9G <git@u9g.dev>
2024-01-25 20:19:35 +08:00