Boshen
01c0c3e4b2
feat(transformer): add remaining options to transformer options ( #5169 )
...
closes #5168
2024-08-24 14:52:03 +00:00
overlookmotel
960e1d5c60
refactor(ast): rename IdentifierReference::new_with_reference_id ( #5157 )
...
The old name `new_read` no longer makes sense as it doesn't set a read-only flag any more, since `flags` field was removed from `IdentifierReference`.
2024-08-24 02:34:18 +00:00
overlookmotel
5136f011d9
refactor(transformer): remove unnecessary type annotation ( #5131 )
...
Remove unnecessary type annotation introduced in #4925 .
2024-08-23 23:10:38 +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
oxc-bot
0b900110a2
Release crates v0.25.0 ( #5107 )
...
## [0.25.0] - 2024-08-23
- 78f135d ast: [**BREAKING**] Remove `ReferenceFlag` from
`IdentifierReference` (#5077 ) (Boshen)
- f2b8d82 semantic: [**BREAKING**] `ScopeTree::get_child_ids` +
`get_child_ids_mut` return value not `Option` (#5058 ) (overlookmotel)
- 5f4c9ab semantic: [**BREAKING**] Rename `SymbolTable::get_flag` to
`get_flags` (#5030 ) (overlookmotel)
- 58bf215 semantic: [**BREAKING**] Rename `Reference::flag` and
`flag_mut` methods to plural (#5025 ) (overlookmotel)
- c4c08a7 ast: [**BREAKING**] Rename
`IdentifierReference::reference_flags` field (#5024 ) (overlookmotel)
- d262a58 syntax: [**BREAKING**] Rename `ReferenceFlag` to
`ReferenceFlags` (#5023 ) (overlookmotel)
- c30e2e9 semantic: [**BREAKING**] `Reference::flag` method return
`ReferenceFlag` (#5019 ) (overlookmotel)
- ce4d469 codegen: [**BREAKING**] Remove const generic `MINIFY` (#5001 )
(Boshen)
- b2ff2df parser: [**BREAKING**] Remove builder pattern from `Parser`
struct (#5000 ) (Boshen)
- f88970b ast: [**BREAKING**] Change order of fields in CallExpression
(#4859 ) (Burlin)
### Features
- 714373d ast: `inherit_variants!` macro add `into_*` methods (#5005 )
(overlookmotel)
- 6800e69 oxc: Add `Compiler` and `CompilerInterface` (#4954 ) (Boshen)
- 2b21be3 oxc_minifier: Define plugin with postfix wildcard (#4979 )
(IWANABETHATGUY)
- afe728a parser: Parse regular expression with regex parser (#4998 )
(Boshen)
- 4b49cf8 transformer: Always pass in symbols and scopes (#5087 )
(Boshen)
- f51d3f9 transformer/nullish-coalescing-operator: Handles nullish
coalescing expression in the FormalParamter (#4975 ) (Dunqing)
- f794870 transformer/nullish-coalescing-operator: Generate the correct
binding name (#4974 ) (Dunqing)
- 72ff2c6 transformer/nullish-coalescing-operator: Add comments in top
of file (#4972 ) (Dunqing)
- 6b885fe traverse: Expose `generate_uid_based_on_node` and
`generate_uid_in_current_scope_based_on_node` from `TraverseCtx` (#4965 )
(Dunqing)
### Bug Fixes
- 7f3129e ast: Correct code comment (#5004 ) (overlookmotel)
- 1bd9365 coverage: Correctly check semantic data after transform
(#5035 ) (Boshen)
- 185eb20 isolated_declarations: Namespaces that are default exported
should be considered for expando functions (#4935 ) (michaelm)
- 2a5e15d npm: `libc` field should not be `null` (Boshen)
- efbdced parser: Only show flow error if it's a flow file (#5069 )
(Boshen)
- ad2be97 semantic: Incorrect semantic check for label has same name
(#5041 ) (heygsc)
- d5de97d semantic: Transform checker check reference flags (#5092 )
(overlookmotel)
- 90c74ee semantic: Transform checker check reference symbol IDs (#5090 )
(overlookmotel)
- a8005b9 semantic: Transform checker check symbol redeclarations
(#5089 ) (overlookmotel)
- 205bff7 semantic: Transform checker check symbol references (#5088 )
(overlookmotel)
- 4a57086 semantic: Transform checker check symbol IDs (#5078 )
(overlookmotel)
- ea7d216 semantic: Transform checker check symbol spans (#5076 )
(overlookmotel)
- 1b6b27a semantic: Transform checker check symbol flags (#5074 )
(overlookmotel)
- 6d87b0f semantic: Fix error message for duplicated label (#5071 )
(Boshen)
- 05fff16 semantic: Transform checker compare binding symbol IDs (#5057 )
(overlookmotel)
- f187b71 semantic: Transform checker compare scope children (#5056 )
(overlookmotel)
- b52c6a4 semantic: Transform checker compare scope parents (#5055 )
(overlookmotel)
- da64014 semantic: Transform checker catch more scope flags mismatches
(#5054 ) (overlookmotel)
- 67d1a96 semantic: Transform checker compare scope flags (#5052 )
(overlookmotel)
- 863b9cb semantic: Transform checker handle conditional scopes (#5040 )
(overlookmotel)
- 47029c4 semantic: Transform checker output symbol names in errors
(#5038 ) (overlookmotel)
- 6ffbd78 transformer: Remove an `AstBuilder::copy` call from TS
namespace transform (#4987 ) (overlookmotel)
- a8dfdda transformer: Remove an `AstBuilder::copy` call from TS module
transform (#4986 ) (overlookmotel)
- 1467eb3 transformer: Remove an `AstBuilder::copy` call from TS enum
transform (#4985 ) (overlookmotel)
- 1365feb transformer: Remove an `AstBuilder::copy` call for TS
`AssignmentTarget` transform (#4984 ) (overlookmotel)
- edacf93 transformer: Remove an `AstBuilder::copy` call (#4983 )
(overlookmotel)
- 3b35332 transformer/logical-assignment-operators: Fix semantic errors
(#5047 ) (Dunqing)- b7db235 Comments gen regression (#5003 )
(IWANABETHATGUY)
### Documentation
- 178d1bd transformer: Add documentation for exponentiation-operator
plugin (#5084 ) (Dunqing)
- d50eb72 transformer: Add documentation for `optional-catch-binding`
plugin (#5064 ) (Dunqing)
- 4425b17 transformer: Add documentation for
`logical-assignment-operators` plugin (#5012 ) (Dunqing)
- 1bd5853 transformer: Updated README re: order of methods (#4993 )
(overlookmotel)
### Refactor
- a4247e9 allocator: Move `Box` and `Vec` into separate files (#5034 )
(overlookmotel)
- cca7440 ast: Replace `AstBuilder::move_statement_vec` with `move_vec`
(#4988 ) (overlookmotel)
- 4012260 ast: `AstBuilder::move_identifier_reference` do not allocate
empty string (#4977 ) (overlookmotel)
- 96422b6 ast: Make AstBuilder non-exhaustive (#4925 ) (DonIsaac)
- ca70cc7 linter, mangler, parser, semantic, transformer, traverse,
wasm: Rename various `flag` vars to `flags` (#5028 ) (overlookmotel)
- 0f64d10 minifier: Remove duplicated helper `move_out_expression`
(#5007 ) (IWANABETHATGUY)
- cd9cf5e oxc: Remove `remove_whitespace` (Boshen)
- b4407c4 oxc,mangler: `oxc` crate add mangler; mangler use options API
(Boshen)
- 9da6a21 semantic: Rename transform checker output for reference symbol
mismatches (#5091 ) (overlookmotel)
- fb46eaf semantic: Add remap functions to transform checker (#5082 )
(overlookmotel)
- a00bf18 semantic: Add `IdMapping` to transform checker (#5079 )
(overlookmotel)
- b14a302 semantic: Transform checker: change symbol name mismatch error
(#5075 ) (overlookmotel)
- b8c6ce5 semantic: Rename vars in transform checker (#5072 )
(overlookmotel)
- 7156fd2 semantic: Transform checker `Pair` structure (#5053 )
(overlookmotel)
- 0ba6f50 semantic: Simplify raising errors in transform checker (#5051 )
(overlookmotel)
- ee7ac8b semantic: Store all data in `PostTransformChecker` in
transform checker (#5050 ) (overlookmotel)
- 4e1f4ab semantic: Add `SemanticIds` to transformer checker (#5048 )
(overlookmotel)
- c1da574 semantic: Add comments to transformer checker (#5045 )
(overlookmotel)
- 8cded08 semantic: Rename error labels in transformer checker snapshots
(#5044 ) (overlookmotel)
- 602244f semantic: Rename vars in transformer checker (#5043 )
(overlookmotel)
- ae94b9a semantic: Remove unused function params in transformer checker
(#5042 ) (overlookmotel)
- 586e15c semantic: Reformat transform checker errors (#5039 )
(overlookmotel)
- d69e34e semantic: Fix indentation (#5037 ) (overlookmotel)
- 4336a32 semantic: Rename fields in snapshots from `flag` to `flags`
(#5032 ) (overlookmotel)
- 83dfb14 semantic: Rename vars from `flag` to `flags` (#5031 )
(overlookmotel)
- 3b7de18 semantic: Rename `SemanticBuilder::current_reference_flags`
field (#5027 ) (overlookmotel)
- 0bacdd8 semantic: Rename `Reference::flag` field to `flags` (#5026 )
(overlookmotel)
- 896b92f semantic: Correct typo in doc comment (#5009 ) (overlookmotel)
- d677b8e semantic: Do not reserve space in `resolved_references`
(#4962 ) (overlookmotel)
- a7ef30d semantic: `UnresolvedReferencesStack` contain only
`ReferenceId` (#4960 ) (overlookmotel)
- 59d15c7 semantic: `root_unresolved_references` contain only
`ReferenceId` (#4959 ) (overlookmotel)
- 7706523 span: Clarify `Atom` conversion methods lifetimes (#4978 )
(overlookmotel)
- 4fdf26d transform_conformance: Add driver (#4969 ) (Boshen)
- 8d15e65 transformer: Use `into_member_expression` (#5006 )
(overlookmotel)
- 4796ece transformer: TS annotations transform use `move_expression`
(#4982 ) (overlookmotel)
- a9fcf29 transformer/es2016: Move all entry points to implementation of
Traverse trait (#5085 ) (Dunqing)
- deda6ac transformer/es2019: Move all entry points to implementation of
Traverse trait (#5065 ) (Dunqing)
- 9df2f80 transformer/es2020: Move all entry points to implementation of
Traverse trait (#4973 ) (Dunqing)
- 3f9433c transformer/es2021: Move all entry points to implementation of
Traverse trait (#5013 ) (Dunqing)
- c60a50d transformer/exponentiation-operator: Use built-in
`ctx.clone_identifier_reference` (#5086 ) (Dunqing)
- bcc8da9 transformer/logical-assignment-operator: Use
`ctx.clone_identifier_reference` (#5014 ) (Dunqing)
- 38d4434 transformer/nullish-coalescing-operator: Move internal methods
to bottom of the file (#4996 ) (Dunqing)
### Testing
- 0df1a94 semantic: Add more symbol and reference checks to
`PostTransformChecker` (Boshen)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-23 15:37:36 +08:00
Dunqing
8cf8f7a58a
feat(traverse): add is_static method to TraverseCtx, which is moves out from SymbolTable ( #5067 )
...
The [scope.isStatic](419644f27c/packages/babel-traverse/src/scope/index.ts (L557) ) method we port it from Babel. This method is useful for `transformer`. So we should move it out from `SymbolTable`, and it would be better to put it to `TraverseCtx`.
2024-08-23 07:14:08 +00:00
Dunqing
c60a50d2f3
refactor(transformer/exponentiation-operator): use built-in ctx.clone_identifier_reference ( #5086 )
2024-08-22 21:21:36 +00:00
Dunqing
a9fcf292fe
refactor(transformer/es2016): move all entry points to implementation of Traverse trait ( #5085 )
...
follow-up #4881
2024-08-22 21:02:32 +00:00
Dunqing
178d1bd986
docs(transformer): add documentation for exponentiation-operator plugin ( #5084 )
...
follow-up #4881
2024-08-22 20:45:41 +00:00
Boshen
4b49cf8ce4
feat(transformer): always pass in symbols and scopes ( #5087 )
...
We no longer need to build semantic data inside the transformer.
The caller should be responsible for handling semantic data and its
errors.
The best way to achieve this in via `CompilerInterface`.
closes #3565
2024-08-22 16:06:31 +00:00
Boshen
78f135d686
refactor(ast)!: remove ReferenceFlag from IdentifierReference ( #5077 )
...
closes #4512
2024-08-22 14:30:50 +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
Dunqing
deda6ac136
refactor(transformer/es2019): move all entry points to implementation of Traverse trait ( #5065 )
...
follow-up #4881
2024-08-22 08:34:44 +00:00
Dunqing
d50eb72399
docs(transformer): add documentation for optional-catch-binding plugin ( #5064 )
...
follow-up #4881
2024-08-22 08:34:42 +00:00
Dunqing
bcc8da96ae
refactor(transformer/logical-assignment-operator): use ctx.clone_identifier_reference ( #5014 )
...
Use TraverseCtx's built-in `clone_identifier_reference`
2024-08-21 09:19:38 +00:00
Dunqing
3f9433ce3b
refactor(transformer/es2021): move all entry points to implementation of Traverse trait ( #5013 )
...
follow-up: #4881
2024-08-21 08:04:43 +00:00
overlookmotel
5f4c9ab38e
refactor(semantic)!: rename SymbolTable::get_flag to get_flags ( #5030 )
...
Part of #4991 .
2024-08-21 00:19:58 +00:00
overlookmotel
ca70cc7c03
refactor(linter, mangler, parser, semantic, transformer, traverse, wasm): rename various flag vars to flags ( #5028 )
...
Part of #4991 .
2024-08-21 00:19:58 +00:00
overlookmotel
58bf21531e
refactor(semantic)!: rename Reference::flag and flag_mut methods to plural ( #5025 )
...
Part of #4991 .
2024-08-21 00:19:57 +00:00
overlookmotel
c4c08a7433
refactor(ast)!: rename IdentifierReference::reference_flags field ( #5024 )
...
Part of #4991 .
2024-08-21 00:19:57 +00:00
overlookmotel
d262a58eb5
refactor(syntax)!: rename ReferenceFlag to ReferenceFlags ( #5023 )
...
Part of #4991 .
2024-08-21 00:19:56 +00:00
overlookmotel
c30e2e9cce
refactor(semantic)!: Reference::flag method return ReferenceFlag ( #5019 )
...
Closes #4992 .
2024-08-20 22:02:08 +00:00
Dunqing
4425b177d4
docs(transformer): add documentation for logical-assignment-operators plugin ( #5012 )
...
follow-up #4881
2024-08-20 16:32:37 +00:00
overlookmotel
8d15e65a78
refactor(transformer): use into_member_expression ( #5006 )
...
Use new `into_member_expression` API introduced in #5005 in TS transforms.
2024-08-20 13:39:26 +00:00
Burlin
f88970bc79
refactor(ast)!: Change order of fields in CallExpression ( #4859 )
...
fix : #4821
---------
Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-08-20 09:47:12 +08:00
Dunqing
38d4434473
refactor(transformer/nullish-coalescing-operator): move internal methods to bottom of the file ( #4996 )
...
follow-up #4993
2024-08-20 01:06:38 +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
Dunqing
9df2f80cab
refactor(transformer/es2020): move all entry points to implementation of Traverse trait ( #4973 )
...
part of #4881
2024-08-20 01:06:36 +00:00
Dunqing
72ff2c67b9
feat(transformer/nullish-coalescing-operator): add comments in top of file ( #4972 )
...
part of #4881
2024-08-20 01:06:35 +00:00
overlookmotel
cca7440d4b
refactor(ast): replace AstBuilder::move_statement_vec with move_vec ( #4988 )
...
Replace `AstBuilder::move_statement_vec` with a general `move_vec` method which handles any kind of `Vec`.
2024-08-19 21:09:14 +00:00
overlookmotel
6ffbd78947
fix(transformer): remove an AstBuilder::copy call from TS namespace transform ( #4987 )
...
Replace an unsafe `AstBuilder::copy` call with `AstBuilder::move_expression` in TS namespace transform.
2024-08-19 21:09:12 +00:00
overlookmotel
a8dfddaeab
fix(transformer): remove an AstBuilder::copy call from TS module transform ( #4986 )
...
Remove an unsafe `AstBuilder::copy` call from TS module transform. `IdentifierReference` is `Clone`, so we can just clone it rather than copy. Same result, but safe.
Also shorten the surrounding code a bit, using `.unwrap()` instead of an `unreachable!()` branch.
2024-08-19 21:09:11 +00:00
overlookmotel
1467eb306c
fix(transformer): remove an AstBuilder::copy call from TS enum transform ( #4985 )
...
Replace an unsafe `AstBuilder::copy` call with `AstBuilder::move_expression` in TS enum transform.
2024-08-19 21:09:10 +00:00
overlookmotel
1365feb6b1
fix(transformer): remove an AstBuilder::copy call for TS AssignmentTarget transform ( #4984 )
...
Add `AssignmentTarget::get_expression_mut` method and use it to remove an unsound `AstBuilder::copy` call from TS transform for `AssignmentTarget`s.
2024-08-19 21:09:09 +00:00
overlookmotel
edacf936ec
fix(transformer): remove an AstBuilder::copy call ( #4983 )
...
Remove one usage of unsound `AstBuilder::copy` method, using the new `get_inner_expression_mut` method introduced in #4920 .
2024-08-19 21:09:07 +00:00
overlookmotel
4796ece77d
refactor(transformer): TS annotations transform use move_expression ( #4982 )
...
Follow on after #4920 . #4920 removed a usage of `AstBuilder::copy` and replaced with 2 new methods `AstBuilder::move_identifier_reference` and `AstBuilder:: move_member_expression`.
We can instead use `AstBuilder::move_expression` earlier and then unpack the enum again. Hopefully the compiler can see that the 2 `unreachable!()` branches are indeed unreachable and elide them.
`move_expression` is preferable to `move_member_expression` as it only creates 1 temporary `Box<Expression::NullLiteral>` instead of 2.
2024-08-19 20:59:43 +00:00
overlookmotel
1bd5853310
docs(transformer): updated README re: order of methods ( #4993 )
...
Add to `oxc_transformer` README note about order methods laid out in
files.
The idea is that you can read code for a transformer from top to bottom,
and the logic flows in this direction.
2024-08-20 04:43:47 +08:00
DonIsaac
96422b6489
refactor(ast): make AstBuilder non-exhaustive ( #4925 )
2024-08-19 05:32:30 +00:00
oxc-bot
5d0fb979cb
Release crates v0.24.3 ( #4950 )
...
## [0.24.3] - 2024-08-18
### Features
- d49fb16 oxc_codegen: Support generate range leading comments (#4898 )
(IWANABETHATGUY)
- 80d0d1f semantic: Check for invalid interface heritage clauses (#4928 )
(DonIsaac)
- 48821c0 semantic,syntax: Add SymbolFlags::ArrowFunction (#4946 )
(DonIsaac)
- f1fcdde transformer: Support react fast refresh (#4587 ) (Dunqing)
- 0d79122 transformer: Support logical-assignment-operators plugin
(#4890 ) (Dunqing)
- ab1d08c transformer: Support `optional-catch-binding` plugin (#4885 )
(Dunqing)
- 69da9fd transformer: Support nullish-coalescing-operator plugin
(#4884 ) (Dunqing)
- 3a66e58 transformer: Support exponentiation operator plugin (#4876 )
(Dunqing)
- f88cbcd transformer: Add `BoundIdentifier::new_uid_in_current_scope`
method (#4903 ) (overlookmotel)
- 1e6d0fe transformer: Add methods to `BoundIdentifier` (#4897 )
(overlookmotel)
- fd34640 traverse: Support `generate_uid_based_on_node` method in
`TraverseCtx` (#4940 ) (Dunqing)
- 72a37fc traverse: Support `clone_identifier_reference` method in
`TraverseCtx` (#4880 ) (Dunqing)
### Bug Fixes
- c0b26f4 ast: Do not include `scope_id` fields in JSON AST (#4858 )
(overlookmotel)
- bbf9ec0 codegen: Add missing `declare` to `PropertyDefinition` (#4937 )
(Boshen)
- f210cf7 codegen: Print `TSSatisfiesExpression` and
`TSInstantiationExpression` (#4936 ) (Boshen)
- 21f5762 codegen: Minify large numbers (#4889 ) (Boshen)
- e8de4bd codegen: Fix whitespace issue when minifying `x in new
Error()` (#4886 ) (Boshen)
- a226962 codegen: Print `TSNonNullExpression` (#4869 ) (Boshen)
- 3da33d3 codegen: Missing parenthesis for `PrivateInExpression` (#4865 )
(Boshen)
- 1808529 codegen: Dedupe pure annotation comments (#4862 )
(IWANABETHATGUY)
- d3bbc62 isolated-declarations: Declare modifier of PropertyDefinition
should not be retained (#4941 ) (Dunqing)
- 8e80f59 isolated_declarations: Class properties should still be lifted
from private constructors (#4934 ) (michaelm)
- b3ec9e5 isolated_declarations: Always emit module declarations that
perform augmentation (#4919 ) (michaelm)
- 0fb0b71 isolated_declarations: Always emit module declarations (#4911 )
(michaelm)
- 4a16916 isolated_declarations: Support expando functions (#4910 )
(michaelm)
- 508644a linter/tree-shaking: Correct the calculation of `>>`, `<<` and
`>>>` (#4932 ) (mysteryven)
- 46cb1c1 minifier: Handle `Object.definedPropert(exports` for
@babel/types/lib/index.js (#4933 ) (Boshen)
- 81fd637 minifier: Do not fold `0 && (module.exports = {})` for
`cjs-module-lexer` (#4878 ) (Boshen)
- 879a271 minifier: Do not join `require` calls for `cjs-module-lexer`
(#4875 ) (Boshen)
- 1bdde2c parser: Detect @flow in `/** @flow */ comment (#4861 ) (Boshen)
- 2476dce transformer: Remove an `ast.copy` from
`NullishCoalescingOperator` transform (#4913 ) (overlookmotel)
- 248a757 transformer/typescript: Typescript syntax within
`SimpleAssignmentTarget` with `MemberExpressions` is not stripped
(#4920 ) (Dunqing)
### Documentation
- 47c9552 ast, ast_macros, ast_tools: Better documentation for `Ast`
helper attributes. (#4856 ) (rzvxa)
- 0a01a47 semantic: Improve documentation (#4850 ) (DonIsaac)
- 9c700ed transformer: Add README including style guide (#4899 )
(overlookmotel)
### Refactor
- a6967b3 allocator: Correct code comment (#4904 ) (overlookmotel)
- 90d0b2b allocator, ast, span, ast_tools: Use `allocator` as var name
for `Allocator` (#4900 ) (overlookmotel)
- 1eb59d2 ast, isolated_declarations, transformer: Mark
`AstBuilder::copy` as an unsafe function (#4907 ) (overlookmotel)
- 8e8fcd0 ast_tools: Rename `oxc_ast_codegen` to `oxc_ast_tools`.
(#4846 ) (rzvxa)
- 786bf07 index: Shorten code and correct comment (#4905 )
(overlookmotel)
- ea1e64a semantic: Make SemanticBuilder opaque (#4851 ) (DonIsaac)
- 5fd1701 sourcemap: Lower the `msrv`. (#4873 ) (rzvxa)
- 48a1c32 syntax: Inline trivial bitflags methods (#4877 )
(overlookmotel)
- 452187a transformer: Rename `BoundIdentifier::new_uid_in_root_scope`
(#4902 ) (overlookmotel)
- 707a01f transformer: Re-order `BoundIdentifier` methods (#4896 )
(overlookmotel)
- 117dff2 transformer: Improve comments for `BoundIdentifier` helper
(#4895 ) (overlookmotel)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-18 14:16:25 +08:00
Dunqing
248a757b34
fix(transformer/typescript): typescript syntax within SimpleAssignmentTarget with MemberExpressions is not stripped ( #4920 )
...
close : #4870
I added the `move_identifier_reference` and `move_member_expression` methods used to take ownership in `ast_builder_impl`. This way can let us get rid of `ast.copy`.
Another possible approach is to add `get_expression_owner` to `SimpleAssignmentTarget` and a `get_inner_expression_owner` method to `Expression`. And add an `into_xxxxx` method for `inherit_variants` macro
The implementation looks like this
```rs
let Some(expression) = self.get_expression_owner() else { return; }
match expr.get_inner_expression_owner() {
Expression::Identifier(ident) => {
*target = self.ctx.ast.simple_assignment_target_from_identifier_reference(ident);
}
inner_expr @ match_member_expression!(Expression) => {
*target = SimpleAssignmentTarget::from(
inner_expr.into_member_expression()
);
}
_ => (),
}
```
2024-08-16 05:05:10 +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
overlookmotel
1eb59d2b5e
refactor(ast, isolated_declarations, transformer): mark AstBuilder::copy as an unsafe function ( #4907 )
...
`AstBuilder::copy` is completely unsound (#3483 ), and we need to remove it. Make it an `unsafe` function to discourage any further usage of it in meantime.
2024-08-15 16:22:43 +01:00
overlookmotel
2476dceee0
fix(transformer): remove an ast.copy from NullishCoalescingOperator transform ( #4913 )
...
Remove one unnecessary `ast.copy` call from `NullishCoalescingOperator` transform (towards #3483 ).
2024-08-15 13:21:48 +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
IWANABETHATGUY
d49fb160e3
feat(oxc_codegen): support generate range leading comments ( #4898 )
...
1. Support print range leading comments for specific expr or stmt
2024-08-15 04:20:48 +00:00
overlookmotel
9c700ed509
docs(transformer): add README including style guide ( #4899 )
...
Add a README to `oxc_transformer` crate, including a "style guide" for
writing transforms. As discussed in #4881 .
2024-08-15 10:52:14 +08:00