github-actions[bot]
1b3cd6c24d
Release crates v0.15.0 ( #3743 )
...
## [0.15.0] - 2024-06-18
- 0537d29 cfg: [**BREAKING**] Move control flow to its own crate.
(#3728 ) (rzvxa)
- 5c38a0f codegen: [**BREAKING**] New code gen API (#3740 ) (Boshen)
- 4bce59d semantic/cfg: [**BREAKING**] Re-export `petgraph` as
`control_flow::graph`. (#3722 ) (rzvxa)
- 534242a codegen: [**BREAKING**] Remove
`CodegenOptions::enable_typescript` (#3674 ) (Boshen)
- 0578ece ast: [**BREAKING**] Remove
`ExportDefaultDeclarationKind::TSEnumDeclaration` (#3666 ) (Dunqing)
### Features
- 5a99d30 codegen: Improve codegen formatting (#3735 ) (Boshen)
- bf9b38a codegen: Improve codegen formatting (#3731 ) (Boshen)
- 4a004e2 codegen: Print TSImport remaining fields (#3695 ) (Dunqing)
- a56cb1b codegen: Print accessibility for MethodDefinition (#3690 )
(Dunqing)
- 38a75e5 coverage: Improve codegen (#3729 ) (Boshen)
- 750a534 coverage: Transformer idempotency test (#3691 ) (Boshen)
- ee627c3 isolated-declarations: Create unique name for `_default`
(#3730 ) (Dunqing)
- 81e9526 isolated-declarations: Inferring set accessor parameter type
from get accessor return type (#3725 ) (Dunqing)
- 77d5533 isolated-declarations: Report errors that are consistent with
typescript. (#3720 ) (Dunqing)
- 8f5655d linter: Add eslint/no-useless-constructor (#3594 ) (Don Isaac)
- 046ff3f linter/eslint: Add `no_unreachable` rule. (#3238 ) (rzvxa)
- 0b8098a napi: Isolated-declaration (#3718 ) (Boshen)
- 527bfc8 npm/oxc-transform: Setup npm/oxc-transform and publish
(Boshen)
- d65c652 parser: Display jsx mismatch error, e.g. `<Foo></Bar>` (#3696 )
(Boshen)
- 9c31ed9 semantic/cfg: Propagate unreachable edges through subgraphs.
(#3648 ) (rzvxa)
- d9c5b33 semantic/cfg: Add `Condition` instruction. (#3567 ) (Ali
Rezvani)
- f2dfd66 semantic/cfg: Add iteration instructions. (#3566 ) (rzvxa)
- 910193e transformer-dts: Report error for super class (#3711 )
(Dunqing)
- 413d7be transformer-dts: Transform enum support (#3710 ) (Dunqing)
- 35c382e transformer-dts: Remove type annotation from private field
(#3689 ) (Dunqing)
- 0e6d3ce transformer-dts: Report error for async function and generator
(#3688 ) (Dunqing)
- b22b59a transformer-dts: Transform namespace support (#3683 ) (Dunqing)
- 4f2db46 transformer-dts: `--isolatedDeclarations` dts transform
(#3664 ) (Dunqing)
### Bug Fixes
- 2158268 ast: Incorrect visit order in function (#3681 ) (Dunqing)
- da1e2d0 codegen: Improve typescript codegen (#3708 ) (Boshen)
- f1b793f isolated-declarations: Function overloads reaching unreachable
(#3739 ) (Dunqing)
- 0fbecdc isolated-declarations: Should be added to references, not
bindings (#3726 ) (Dunqing)
- 8f64d99 minifier: Respect `join_vars: false` option (#3724 )
(mysteryven)
- 70fc69b semantic: Add Eq to CtxFlags (#3651 ) (Yuji Sugiura)
- 7a58fec semantic/cfg: Issue in unlabeled `Ctx`s. (#3678 ) (rzvxa)
- abd6ac8 semantic/cfg: Discrete finalization path after `NewFunction`s.
(#3671 ) (rzvxa)
- e148a32 semantic/cfg: Correct unreachability propagation in
try-finally. (#3667 ) (Ali Rezvani)
- 59666e0 transformer: Do not rename accessible identifier references
(#3623 ) (Dunqing)
- 90743e2 traverse: Change visit order for `Function` (#3685 )
(overlookmotel)
### Performance
- 2717a1a semantic/cfg: Lower the visits in
`neighbors_filtered_by_edge_weight`. (#3676 ) (rzvxa)
### Refactor
- fa7a6ba codegen: Add `gen` method to ast nodes (#3687 ) (Boshen)
- 09b92b6 codegen: Move `gen_ts` into `gen` to make searching things
easier (#3680 ) (Boshen)
- 3c59735 isolated-declarations: Remove `TransformDtsCtx` (#3719 )
(Boshen)
- 815260e isolated-declarations: Decouple codegen (#3715 ) (Boshen)
- 7ec44f8 semantic: Rename `cfg` macro to `control_flow`. (#3742 )
(rzvxa)
- d8ad321 semantic: Make control flow generation optional. (#3737 )
(rzvxa)
- a94a72d semantic: Expose 1 checker function instead of 2 (#3694 )
(Boshen)
- bd8d115 semantic/cfg: Remove unused types. (#3677 ) (rzvxa)
- f702fb9 semantic/cfg: Cleanup control flow and it's builder. (#3650 )
(rzvxa)
- 4f16664 transformer_dts: Create a `Program` for codegen (#3679 )
(Boshen)
Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-19 01:15:55 +08:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt
2024-06-19 00:48:30 +08:00
github-actions[bot]
95e0571c2e
Release crates v0.14.0 ( #3643 )
...
## [0.14.0] - 2024-06-12
### Breaking
* fix(codegen)!: remove the unecessary 4th argument from `Codegen::new`
(#3640 )
* feat(ast)!: make `Trivias` clonable by adding `Arc` (#3638 )
### Features
- f6d9ca6 linter: Add `eslint/sort-imports` rule (#3568 ) (Wang Wenzhe)
- 129f91e span: Port over more methods from TextRange (#3592 ) (Don
Isaac)
### Bug Fixes
- f8f6d33 ast: Correct `visited_node` attr for strict mode of arrow fns
(#3635 ) (overlookmotel)
- e6ad3fb diagnostics: Do not print ansi color codes in non-TTYs (#3624 )
(Boshen)
- d65202d span: Correct doc comments (#3608 ) (overlookmotel)
- 35e267b transformer: Arrow function transform use UIDs for `_this`
vars (#3634 ) (overlookmotel)
- 39bdebc transformer: Arrow func transform maintain scope ID (#3633 )
(overlookmotel)
- 5cb7e6a transformer: Arrow func transform use correct spans (#3630 )
(overlookmotel)
- 0c4ccb4 transformer: Arrow function transform alter `</this>` (#3627 )
(overlookmotel)
- 8d237c4 transformer: JSX source calculate correct column when Unicode
chars (#3615 ) (overlookmotel)
- 9e8f4d6 transformer: Do not add `__source` for generated nodes (#3614 )
(overlookmotel)
- 0fb4c35 transformer: Use UID for JSX source filename var (#3612 )
(overlookmotel)
### Performance
- 3a59294 transformer: React display name transform reduce Atom
allocations (#3616 ) (overlookmotel)
- f4c1389 transformer: Create `Vec` with capacity (#3613 )
(overlookmotel)
### Refactor
- 0f92521 ast: Replace recursion with loop (#3626 ) (overlookmotel)
- 08f1010 ast: Make `AstBuilder` `Copy` (#3602 ) (overlookmotel)
- 84304b4 linter: Add a `ctx.module_record()` method (#3637 ) (Boshen)
- f98f777 linter: Add rule fixer (#3589 ) (Don Isaac)
- e90e6a2 minifier: Make `Prepass` `Copy` (#3603 ) (overlookmotel)
- 7d61832 semantic: Pass `Rc` by value (#3586 ) (overlookmotel)
- 89bcbd5 transformer: Move `BoundIdentifier` into helpers (#3610 )
(overlookmotel)
- 5793ff1 transformer: Replace `&’a Trivias` with `Rc<Trivias>` (#3580 )
(Dunqing)
- 509871f transformer: Comment for unimplemented `spec` option in arrow
fns transform (#3618 ) (overlookmotel)
- 4b2e3a7 transformer: Fix indentation (#3617 ) (overlookmotel)
- 3467e3d transformer: Remove outdated comment (#3606 ) (overlookmotel)
- a799225 transformer: Flatten file structure for React transform
(#3604 ) (overlookmotel)
- 70f31a8 transformer: Reduce branching in JSX transform (#3596 )
(overlookmotel)
- 3ae567d transformer: Remove dead code (#3588 ) (overlookmotel)
- 60cbdec traverse: `generate_uid_in_root_scope` method (#3611 )
(overlookmotel)
Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-12 17:52:41 +08:00
github-actions[bot]
6bdd74c476
Release crates v0.13.5 ( #3584 )
...
## [0.13.5] - 2024-06-08
### Bug Fixes
- 48bb97e traverse: Do not publish the build script (Boshen)
Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-08 16:44:50 +08:00
Boshen
060819894d
chore: crates should only publish src and examples directory
2024-06-08 16:35:16 +08:00
github-actions[bot]
d215e3d906
Release crates v0.13.4 ( #3582 )
...
## [0.13.4] - 2024-06-07
### Features
- 5c8e16c coverage: Second transformer build does not print typescript
(#3561 ) (Dunqing)
- 646b993 coverage/transformer: Handle @jsx option (#3553 ) (Dunqing)
- a939ddd transformer/typescript: Remove more typescript ast nodes
(#3563 ) (Dunqing)
- e8a20f8 transformer/typescript: Remove typescript ast nodes (#3559 )
(Dunqing)
- ee9a215 transformer/typescript: Handle namespace directive correctly
(#3532 ) (Dunqing)
### Bug Fixes
- affb2c8 codegen: Print indentation before directive (#3512 ) (Dunqing)
- f6939cb transformer: Store `react_importer` in `Bindings` in JSX
transform (#3551 ) (overlookmotel)
- 7982b93 transformer: Correct spans for JSX transform (#3549 )
(overlookmotel)
- c00598b transformer: JSX set `reference_id` on refs to imports (#3524 )
(overlookmotel)
### Performance
- 37cdc13 transformer: Faster checks if JSX plugin enabled (#3577 )
(overlookmotel)
- 9f467b8 transformer: Avoid fragment update where possible (#3535 )
(overlookmotel)
- ac394f0 transformer: JSX parse pragma only once (#3534 )
(overlookmotel)
### Documentation
- 1d3c0d7 span: Add doc comments to `oxc_span::Span` (#3543 ) (Don Isaac)
### Refactor
- f2113ae transformer: Reduce cloning and referencing `Rc`s (#3576 )
(overlookmotel)
- 0948124 transformer: Pass `Rc`s by value (#3550 ) (overlookmotel)
- e4d74ac transformer: Remove `update_fragment` from JSX transform
(#3541 ) (overlookmotel)
- 73b7864 transformer: Combine import and usage in JSX transform (#3540 )
(overlookmotel)
- 6978269 transformer/typescript: Replace reference collector with
symbols references (#3533 ) (Dunqing)
Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-07 17:41:11 +08:00
Boshen
1dbc23417d
chore: regenerate changelogs with commit id and author
2024-06-07 01:22:28 +08:00
Boshen
769227b7b4
chore: regenerate changelogs
2024-06-06 15:51:53 +08:00
Boshen
509ed2bcf3
ci: update prepare release crates; regenerate the changelogs
2024-06-06 14:28:51 +08:00
Boshen
0674604d7a
chore: regenerate changelog
2024-06-06 01:29:38 +08:00
overlookmotel
c00598b9d4
fix(transformer): JSX set reference_id on refs to imports ( #3524 )
...
Set `reference_id` for references to new imported bindings. e.g. `_jsx`
in `_jsx(Foo, {})` where JSX transform has inserted `import {jsx as
_jsx} from "react/jsx-runtime";`.
2024-06-05 10:57:05 +08:00
github-actions[bot]
d48e62aca4
Publish crates v0.13.3 ( #3527 )
...
Automated Release
Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-04 18:02:40 +08:00
github-actions[bot]
079d42f68b
Release crates v0.13.2 ( #3513 )
...
Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-03 12:40:53 +08:00
Boshen
86beca5379
Release crates v0.13.1
2024-05-22 16:50:30 +08:00
Boshen
e2dd8ac8fc
feat(syntax): export is_reserved_keyword and is_global_object method ( #3384 )
2024-05-22 04:58:04 +00:00
Boshen
1e84644220
chore: update toml format
2024-05-21 22:15:47 +08:00
Boshen
bd8a0ddb7f
feat(linter): no-barrel-file ( #3275 )
...

2024-05-16 07:54:09 +00:00
Boshen
c395f8641e
Release crates v0.13.0
2024-05-14 23:14:15 +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
overlookmotel
4e20b04acc
fix(traverse): create scope for function nested in class method ( #3234 )
...
Fixes a bug in #3229 .
The logic to prevent a duplicate scope being created for a `Function` which is a `MethodDefinition` would also stop a scope being created for inner function in:
```rs
class X {
foo() {
function bar() {}
}
}
```
or
```rs
class X {
foo( bar = function() {} ) {}
}
```
This PR fixes that. This change also allows removing `ScopeFlags::Method` which #3229 added.
2024-05-11 12:07:00 +00:00
overlookmotel
46c02aee61
feat(traverse): add scope flags to TraverseCtx ( #3229 )
...
Add scope flags to `TraverseCtx`.
Closes #3189 .
`walk_*` functions build a stack of `ScopeFlags` as AST is traversed, and they can be queried from within visitors with `ctx.scope()`, `ctx.ancestor_scope()` and `ctx.find_scope()`.
The codegen which generates `walk_*` functions gets the info about which AST types have scopes, and how to check for strict mode from the `#[visited_node]` attrs on AST type definitions in `oxc_ast`.
A few notes:
Each scope inherits the strict mode flag from the level before it in the stack, so if you need to know "am I in strict mode context here?", `ctx.scope().is_strict_mode()` will tell you - no need to travel back up the stack to find out.
Scopes do *not* inherit any other flags from level before it. So `ctx.scope()` in a block nested in a function will return `ScopeFlags::empty()` not `ScopeFlags::Function`.
I had to add an extra flag `ScopeFlags::Method`. The reason for this is to deal with when a `Function` is actually a `MethodDefinition`, and to avoid creating 2 scopes in this case. The principle I'm trying to follow is to encode as little logic in the codegen as possible, as it's rather hidden away. Instead the codegen follows a standard logic for every node, guided by attributes which are visible next to the types in `oxc_ast`. This hopefully makes how `Traverse`'s visitors are generated less mysterious, and easier to change.
The case of `Function` within `MethodDefinition` is a weird one and would not be possible to implement without encoding a magic "special case" within the codegen without this extra `ScopeFlags::Method` variant. Its existence does not alter the operation of any other code in Oxc which uses `ScopeFlags`.
In my view `ScopeFlags` might benefit from a little bit of an overhaul anyway. I believe we could pack more information into the bits and make it more useful.
2024-05-11 04:39:42 +00:00
Boshen
f1ccbd4856
feat(syntax): add ToJsInt32 trait for f64 ( #3132 )
2024-04-29 21:13:04 +08:00
Boshen
870d11f1bb
feat(syntax): add ToJsString trait for f64 ( #3131 )
2024-04-29 21:00:04 +08:00
Boshen
a8af5de8f5
refactor(syntax): move number related functions to number module ( #3130 )
2024-04-29 18:54:35 +08:00
Boshen
ae6561308c
refactor(syntax): use FxHashMap for ModuleRecord::request_modules ( #3124 )
...
closes #3121
The ordering is not important here.
2024-04-29 03:37:34 +00:00
Boshen
559bca86c5
Release crates v0.12.5
2024-04-22 12:52:17 +08:00
Ali Rezvani
e6d11c6190
feat(syntax): module graph visitor. ( #3062 )
...
I've tried too hard to make it into a full-fledged depth first iterator, But had no success with it; It is the next best thing that I could've thought of.
Provides a way to visit the module graph from a ModuleRecord as its entry point.
2024-04-22 10:10:27 +08:00
Boshen
1f7033e7ab
fix(semantic): correctly resolve identifiers inside parameter initializers ( #3046 )
...
close : #2644
This fixes function parameters. I think we need an extra AST node to fix catch parameters, which will be the next PR.
2024-04-21 23:38:31 +08:00
overlookmotel
1249c6c326
refactor(ast): implement same traits on all fieldless enums ( #3031 )
...
Implement same traits on all AST fieldless enums, for consistency. Just
a little bit of tidying.
2024-04-20 01:53:48 +08:00
Boshen
a05c4e39b8
Release crates v0.12.4
2024-04-19 16:40:05 +08:00
Boshen
614f73b66c
Release crates v0.12.3
2024-04-11 16:18:17 +08:00
Boshen
09452659e2
Release crates v0.12.2
2024-04-08 11:13:13 +08:00
Don Isaac
1ea24ea0a7
fix(semantic): symbols inside functions and classes incorrectly flagged as exported ( #2896 )
...
# What This PR Does
Symbols declared inside exported functions and classes were being
incorrectly flagged with `SymbolFlags::Export`.
For example,
```ts
export function foo<T>(a: T) {
let b = String(a)
return b
}
```
`T`, `a`, and `b` were all flagged as exported.
## Further Work
It doesn't seem like exported enums and interfaces are being included in
`ModuleRecord`. Am I looking in the wrong place, or are they actually
missing?
2024-04-05 23:01:27 +08:00
Boshen
366a7fb0d4
Release crates v0.11.2
2024-04-03 19:36:54 +08:00
Boshen
54f7cd3978
Release crates v0.11.1
2024-04-03 16:57:52 +08:00
Boshen
23d3c4e0a4
chore: add changelogs via git cliff ( #2878 )
...
This is generated alongside https://github.com/oxc-project/release-oxc
2024-04-01 20:04:48 +08:00
Boshen
7710d8caf1
feat(transformer): add compiler assumptions ( #2872 )
...
closes #2869
2024-03-31 02:04:21 +00:00
Boshen
31ed532b79
Release crates v0.11.0
2024-03-30 13:54:53 +08:00
Dunqing
df628289ff
fix(linter/import): ignore export declaration in no-duplicates ( #2863 )
2024-03-30 12:57:43 +08:00
Dunqing
1b5e544a36
refactor(semantic): distinguish whether requested_modules is type imports/exports ( #2848 )
2024-03-29 19:52:30 +08:00
Dunqing
712b3d2a11
feat(semantic): distinguish type imports in ModuleRecord ( #2785 )
...
I am not sure moving `ImportOrExportKind` to `oxc-syntax` is a good
solution.
2024-03-23 21:38:17 +08:00
overlookmotel
75226f3b4a
chore: silence erroneous RA warnings for Tsify ( #2731 )
2024-03-15 12:42:12 +00:00
Boshen
a5ddb5b452
Release crates v0.10.0
2024-03-14 18:23:34 +08:00
Boshen
697b6b70c0
feat: merge features serde and wasm to serialize ( #2716 )
...
This PR merges the previous confusing features `serde` and `wasm` into a
single `serialize` feature.
We'll eventually do serialize + type information for both wasm and napi
targets.
`oxc_macros` is removed from `oxc_ast`'s dependency because it requires
`syn` and friends, which goes against our policy ["Third-party
dependencies should be
minimal."](https://oxc-project.github.io/docs/contribute/rules.html#development-policy )
2024-03-14 17:13:12 +08:00
overlookmotel
89e8d1526f
refactor: derive SerAttrs on all AST types ( #2698 )
...
Add `SerAttrs` derive to a few types that I missed out in #2669 .
2024-03-13 00:14:04 +00:00
Boshen
366a87975d
feat(linter): resolve ESM star exports ( #2682 )
2024-03-11 21:43:11 +08:00
overlookmotel
3c1e0db53f
refactor: reduce cfg_attr boilerplate with SerAttrs derive ( #2669 )
...
Closes #2641 .
Also added `tsify` attribute to the `SerAttrs` derive macro, so `#[cfg_attr(feature = "wasm", tsify(...))]` can also be reduced to `#[tsify(...)]`.
2024-03-11 13:38:24 +08:00
overlookmotel
cba1e2f338
refactor(ast): import Tsify to shorten code ( #2665 )
...
Pure refactor. Import `tsify::Tsify` in files that use it, so then shorten a load of:
```diff
- #[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
+ #[cfg_attr(feature = "wasm", derive(Tsify))]
```
2024-03-11 12:37:10 +08:00
overlookmotel
d76ee6b2db
refactor: "wasm" feature enable "serde" feature ( #2639 )
...
Make `wasm` feature also enable `serde` feature. This allows shortening
a lot of `#[cfg_attr]`s.
As discussed in
https://github.com/oxc-project/oxc/pull/2638#issuecomment-1984066757 .
2024-03-08 10:06:49 +08:00
overlookmotel
6b5723cdbe
refactor(ast): shorten manual TS defs ( #2638 )
...
Does the same thing, just (in my opinion) a little bit more readable.
2024-03-08 00:53:51 +08:00