overlookmotel
b9c8a10219
fix(wasm): transfer AST to JS as JSON string in oxc-wasm ( #9269 )
...
Same as #9259 , but for `oxc-wasm` package.
This fixes a couple of bugs - previously `RegExp`s and `BigInt`s were
deserialized as `null`.
Only differences from the implementation in
[@oxc-parser/wasm](https://www.npmjs.com/package/@oxc-parser/wasm ) are:
1. Getter for `ast` does not cache the result of `JSON.parse`. I
couldn't quite get my head around Playground code, but I *think* the
`Oxc` class instance is being used as a singleton, and therefore the
value may change as the user updates the source code.
2. JSON is pretty-printed. This is so that when "Raw" is ticked, the
JSON can be displayed exactly as it came out of the parser (rather than
stringifying the AST object again).
2025-02-21 21:56:58 +08:00
overlookmotel
216b33fd2a
feat(ast/estree)!: replace serde with custom ESTree serializer ( #9256 )
...
Replace `serde` with a custom serializer specialized for writing JSON.
`impl Serialize` -> `impl ESTree`. I've called it `ESTree` in case we
want to add e.g. `impl Babel` later on.
The main motivation is that with control of the serializer, we can make
it stateful, so we can extend it to, for example, omit TS fields based
on a flag. This is pretty much impossible with `serde`'s interface.
But a side-effect of the simpler implementation is that it's also more
performant.
The usage of `ESTree` trait is very similar to `serde::Serialize`. Main
differences:
* `serialize` method is infallible. Does not return a `Result`.
* `state = serializer.serialize_struct();` instead of `map =
serializer.serialize_map();`.
* `state.serialize_field(...)` instead of `map.serialize_entry(...)`.
* Struct keys must be strings, and JSON-safe (not including `"` or other
characters that require escaping in JSON).
This is a breaking change, as it's possible downstream consumers are
using `serde` to serialize our AST to other formats. I'd guess unlikely,
but possible. We can always implement `serde::Serialize` as well as
`ESTree` further down the line if there's a demand.
2025-02-21 12:20:26 +08:00
overlookmotel
5acc6ec3e9
fix(wasm): transfer AST to JS as JSON string ( #9259 )
...
In [@oxc-parser/wasm](https://www.npmjs.com/package/@oxc-parser/wasm ) NPM package, transfer the AST to JS as a JSON string, and parse it to a `Program` object on JS side.
This fixes a couple of bugs - previously `RegExp`s and `BigInt`s were deserialized as `null`.
The mechanism for doing this is pretty hacky. After `wasm-pack` generates the JS binding files, a script modifies these files to add a getter for `program` property on `ParseResult`. That getter deserializes the JSON to a `Program`.
The hackyness is not ideal, but I'm not familiar enough with WASM build systems to see if there's a better way. This does at least seem to work!
2025-02-20 14:37:19 +00:00
Arnaud Barré
8d7ceeeed4
ci(napi/transform): validate napi dts files ( #9183 )
...
---------
Co-authored-by: Dunqing <dengqing0821@gmail.com >
2025-02-18 17:14:22 +08:00
renovate[bot]
5681e414bc
chore(deps): lock file maintenance rust crates ( #9167 )
2025-02-17 16:01:35 +08:00
oxc-bot
3576318706
release(crates): v0.51.0 ( #9135 )
...
## [0.51.0] - 2025-02-15
- 21a9476 ast: [**BREAKING**] Remove `TSLiteral::RegExpLiteral` (#9056 )
(Dunqing)
- 9091387 ast: [**BREAKING**] Remove `TSType::TSQualifiedName` (#9051 )
(Dunqing)
### Features
- f74d462 ast_tools: Introduce meta types (#9117 ) (overlookmotel)
- 36c8640 ecmascript: Support more string concatenation (#9121 )
(sapphi-red)
- 6936b08 ecmascript: Fold `typeof` with ValueType information (#9086 )
(sapphi-red)
- b25b84b minifier: Substitute redundant assignment target bindings
(#9096 ) (camchenry)
- 125d610 minifier: Fold String::charAt / String::charCodeAt more
precisely (#9082 ) (sapphi-red)
- 237ffba minifier: Fold bitwise binary expressions with negative
BigInts (#9081 ) (sapphi-red)
- 24830e6 minifier: Fold `a + 'a' + 1` to `a + 'a1'` (#9080 )
(sapphi-red)
- b5eb6e5 minifier: Improve `remove_unused_expression` (#9071 ) (Boshen)
- fef82ff transformer/helper-loader: Replace `@babel/runtime` with
`@oxc-project/runtime` (#9059 ) (Dunqing)
### Bug Fixes
- 38f81af ast/estree: Order fields same as Acorn (#9128 ) (overlookmotel)
- 67f8932 ast/estree: `CatchParameter` do not include `type` and `Span`
twice (#9125 ) (overlookmotel)
- 1b02fe0 ast/estree: `FormalParameter` do not include `Span` twice
(#9124 ) (overlookmotel)
- d3b5fb0 ast/estree: Fix TS type for
`AssignmentTargetPropertyIdentifier` (#9092 ) (overlookmotel)
- d8d80a9 ast/estree: Fix TS types for `BigIntLiteral` and
`RegExpLiteral` (#9091 ) (overlookmotel)
- d9684af codegen: Fix missing StringLiteral sourcemap (#9064 )
(hi-ogawa)
- eb7cd62 ecmascript: To_number for shadowed undefined (#9106 )
(sapphi-red)
- 8cbdf00 ecmascript: To_boolean for shadowed undefined (#9105 )
(sapphi-red)
- 17c745c ecmascript: To_string for object with toString (#9104 )
(sapphi-red)
- cfc71f9 ecmascript: To_string for shadowed undefined (#9103 )
(sapphi-red)
- 2ab2a8f ecmascript: Handle shadowed global variables in `ValueType`
(#9085 ) (sapphi-red)
- bc64c9d lexer: Fix decoding lone `\r` in template literals (#9066 )
(overlookmotel)
- 2fd1589 minifier: Compress computed string literals in method/property
definitions (#9126 ) (camchenry)
- 0937a55 napi/parser: Utf16 span for errors (#9112 ) (hi-ogawa)
- 15f23f1 napi/parser: Utf16 span for module record (#9093 ) (hi-ogawa)
- 9edfb1d napi/parser: Fix unicode comment panic (#9084 ) (hi-ogawa)
- 5f15605 npm/runtime: Incorrect file paths in `exports` (#9069 )
(Dunqing)
- b8278d8 parser: Parse `let _: null` as `TSNullKeyword` (#9133 )
(Boshen)
### Performance
- af59945 napi/parser: Do not convert comment spans twice (#9087 )
(overlookmotel)
### Documentation
- 896d770 ast: Add missing docs and fix broken code for assignment
targets (#9095 ) (camchenry)
### Refactor
- 08b2d80 ast/estree: Define TS types for extra fields on converters
(#9118 ) (overlookmotel)
- 6c5a435 ast/estree: Define types for `#[estree(add_fields)]`
converters (#9116 ) (overlookmotel)
- 8bd6eef ecmascript: Merge constant evaluation logics (#9120 )
(sapphi-red)
- b164072 ecmascript: Extract to_numeric (#9111 ) (sapphi-red)
- fc53cdd ecmascript: Generalize ToPrimitive (#9109 ) (sapphi-red)
- d951390 ecmascript: Use value_type in to_primitive (#9108 )
(sapphi-red)
- 8f79012 ecmascript: Pass IsGlobalReference to DetermineValueType
instead of extending it (#9107 ) (sapphi-red)
- db1744c ecmascript: Remove "constant_evaluation" / "side_effects"
features (#9114 ) (sapphi-red)
- 329de94 ecmascript: Extract ToPrimitive (#9102 ) (sapphi-red)
- d670ec7 ecmascript: Pass IsGlobalReference to MayHaveSideEffects
instead of extending it (#9101 ) (sapphi-red)
- f4e2d4e ecmascript: Allow IsGlobalReference to return None (#9100 )
(sapphi-red)
- 29be94d minifier: Inline more minification methods (#9088 ) (Boshen)
- 80f719e minifier: Clean up minimize_statements.rs (#9076 ) (Boshen)
- d5edde0 minifier: Minimize `if (!foo) foo = bar;` -> `foo ||= bar` in
the same AST pass (#9075 ) (Boshen)
### Styling
- 23f53c0 syntax: Name trait method param without underscore (#9119 )
(overlookmotel)
### Testing
- eaff3d9 napi/parser: Split tests for `convertSpanUtf16` (#9113 )
(hi-ogawa)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com >
2025-02-15 23:00:28 +08:00
Boshen
df3eef81e6
chore(napi/parser): use vitest bench instead of tinybench ( #9134 )
...
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com >
2025-02-15 14:42:48 +08:00
hi-ogawa
eaff3d985f
test(napi/parser): split tests for convertSpanUtf16 ( #9113 )
...
Minor cleanup. I was smashing all assertions in a single `it`, but I've wanted to split them.
2025-02-14 12:58:58 +00:00
hi-ogawa
0937a55b3b
fix(napi/parser): utf16 span for errors ( #9112 )
2025-02-14 12:58:58 +00:00
hi-ogawa
15f23f1556
fix(napi/parser): utf16 span for module record ( #9093 )
...
I (and mostly copilot) wrote `VisitMutModuleRecord` to visit all spans as I wasn't sure how `VisitMut` is generated. I'm looking into visit generator now if it's something I can do. Please let me know if manually writing it down is fine for now or I should try macro (or maybe a completely different approach).
2025-02-14 08:00:57 +00:00
overlookmotel
af5994594c
perf(napi/parser): do not convert comment spans twice ( #9087 )
...
Follow-on after #9079 . We were converting the spans of comments to UTF16 twice - once in `program.comments`, and again in `comments`.
2025-02-13 23:42:15 +00:00
hi-ogawa
9edfb1d330
fix(napi/parser): fix unicode comment panic ( #9084 )
...
- closes https://github.com/oxc-project/oxc/issues/9079
I'm still leaving an existing TODO for `module_record` and `errors` span not being converted as they won't cause an immediate issue, but I'll work on that shortly.
2025-02-13 10:02:37 +00:00
oxc-bot
f237e2af60
release(crates): v0.50.0 ( #9050 )
2025-02-12 11:15:04 +08:00
overlookmotel
41dba62780
fix(ast/estree): set value for BigIntLiterals and RegExpLiterals on JS side ( #9044 )
...
Add a "reviver" function to `JSON.parse` in NAPI parser module, to correctly set `value` field of `Literal`s for `RegExp`s and `BigInt`s.
Surprisingly, judging by a local run of NAPI parser benchmarks (added in #9045 ), this does not seem to hurt performance. In fact the benchmarks were showing a ~2% speed-up. That's clearly nonsense - just noise - but it does suggest at least that this isn't hurting performance significantly.
2025-02-11 14:48:43 +00:00
overlookmotel
ef553b92ad
test(napi): add NAPI parser benchmark ( #9045 )
...
Add a quick benchmark for NAPI parser. It's included in our CI benchmarks, because likely will produce too much variance, but it's useful for local runs.
2025-02-11 14:09:46 +00:00
hi-ogawa
81c81a7cb5
feat(napi/parser): add convert_span_utf16 option ( #8983 )
...
For starter, I added opt-in `convert_span_utf16` for `napi/parser` level option, so rolldown-vite can start to battle test estree output.
2025-02-11 06:21:54 +00:00
oxc-bot
dd927a6851
release(crates): v0.49.0 ( #9015 )
2025-02-10 23:12:03 +08:00
hi-ogawa
4803059925
test(ast): remove old ast snapshot tests ( #8976 )
2025-02-09 04:14:36 +00:00
overlookmotel
a4a8e7deda
style(all): replace #[allow] with #[expect] ( #8930 )
...
Replace `#[allow]` with `#[expect]` through the whole codebase.
This also surfaced many places where the `#[allow]` attributes were outdated/pointless and could be removed entirely.
Only places `#[allow]` remains are:
1. In generated code and macros, where lint errors may or may not be triggered depending on the generated code.
2. A few places where clippy malfunctions. These use e.g. `#[allow(unused, clippy::allow_attributes)]`.
2025-02-07 14:50:02 +00:00
Hiroshi Ogawa
a520986e1a
fix(ast): estree compat Program.sourceType ( #8919 )
...
part of https://github.com/oxc-project/oxc/issues/2854
ref: https://github.com/estree/estree/blob/master/es2015.md#programs
I tried to move `via` customization on `struct SourceType`, but couldn't
find a way maybe because struct is defined in `oxc_span`. For now, I
made this as `via` on `Program::source_type` field.
2025-02-06 13:18:32 +00:00
Hiroshi Ogawa
e30cf6aeb1
fix(ast): estree compat MemberExpression ( #8921 )
...
Part of https://github.com/oxc-project/oxc/issues/2854
I added a bit weird macro `add_entry(computed = true)` to add constant.
Likely this is not the best way. I would appreciate any suggestion for a
better approach 🙏
---------
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com >
2025-02-06 11:50:31 +00:00
Hiroshi Ogawa
0c55dd684e
fix(ast): serialize Function.params like estree ( #8772 )
...
- part of https://github.com/oxc-project/oxc/issues/2854
This PR attempts to handle estree ast incompatibility of
`Function.params: FormalParameters` as mentioned in the above issue:
> `FormalParameters` is closer to ESTree now, but should be inlined
directly into `<node>.params` in multiple nodes.
Estree spec has `Function.params: Pattern[]`
https://github.com/estree/estree/blob/master/es5.md#functions , but oxc
already has `interface Pattern`, so I named it to `Function.params:
ParamPattern[]` for now.
Also I'm not sure about the testing (I suppose that's a part of
https://github.com/oxc-project/oxc/issues/8630 ), so I snapshoted one
example code. For comparison, here is acorn's output
https://astexplorer.net/#/gist/25138c0605f82dcfc1a8fd363dc2a681/5ad30d36c9f276519063e6fd2e340c113d8c85b0
---------
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com >
2025-02-05 02:40:02 +00:00
oxc-bot
dfe2254869
release(crates): v0.48.2 ( #8838 )
2025-02-02 17:36:24 +08:00
oxc-bot
2fb08b9e9c
release(crates): v0.48.1 ( #8738 )
...
## [0.48.1] - 2025-01-26
### Features
- b7f13e6 ast: Implement utf8 to utf16 span converter (#8687 ) (Boshen)
- 6589c3b mangler: Reuse variable names (#8562 ) (翠 / green)
- 29bd215 minifier: Minimize `Infinity.toString(radix)` to `'Infinity'`
(#8732 ) (Boshen)
- e0117db minifier: Replace `const` with `let` for non-exported
read-only variables (#8733 ) (sapphi-red)
- 9e32f55 minifier: Evaluate `Math.sqrt` and `Math.cbrt` (#8731 )
(sapphi-red)
- 360d49e minifier: Replace `Math.pow` with `**` (#8730 ) (sapphi-red)
- 2e9a560 minifier: `NaN.toString(radix)` is always `NaN` (#8727 )
(Boshen)
- cbe0e82 minifier: Minimize `foo(...[])` -> `foo()` (#8726 ) (Boshen)
- e9fb5fe minifier: Dce pure expressions such as `new Map()` (#8725 )
(Boshen)
### Bug Fixes
- 0944758 codegen: Remove parens from `new (import(''), function() {})`
(#8707 ) (Boshen)
- 33de70a mangler: Handle cases where a var is declared in a block scope
(#8706 ) (翠 / green)
- d982cdb minifier: `Unknown.fromCharCode` should not be treated as
`String.fromCharCode` (#8709 ) (sapphi-red)
- e7ab96c transformer/jsx: Incorrect `isStaticChildren` argument for
`Fragment` with multiple children (#8713 ) (Dunqing)
- 3e509e1 transformer/typescript: Enum merging when same name declared
in outer scope (#8691 ) (branchseer)
### Performance
- dc0b0f2 manger: Remove useless `tmp_bindings` (#8735 ) (Dunqing)
- e472ced mangler: Optimize handling of collecting lived scope ids
(#8724 ) (Dunqing)
- 8587965 minifier: Normalize `undefined` to `void 0` before everything
else (#8699 ) (Boshen)
### Refactor
- 58002e2 ecmascript: Remove the lifetime annotation on
`MayHaveSideEffects` (#8717 ) (Boshen)
- 10e5920 linter: Move finishing default diagnostic message to
`GraphicalReporter` (#8683 ) (Sysix)
- 52a37d0 mangler: Simplify initialization of `slots` (#8734 ) (Dunqing)
- 6bc906c minifier: Allow mutating arguments in methods called from
`try_fold_known_string_methods` (#8729 ) (sapphi-red)
- bf8be23 minifier: Use `Ctx` (#8716 ) (Boshen)
- 0af0267 minifier: Side effect detection needs symbols resolution
(#8715 ) (Boshen)
- 32e0e47 minifier: Clean up `Normalize` (#8700 ) (Boshen)
- c792068 semantic: Simplify `ScopeTree::iter_bindings` (#8723 )
(Dunqing)
### Testing
- 03229c5 minifier: Fix broken tests (#8722 ) (Boshen)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com >
2025-01-26 22:20:13 +08:00
oxc-bot
8a72b8ecc7
release(crates): v0.48.0 ( #8686 )
...
## [0.48.0] - 2025-01-24
- 54d0fac span: [**BREAKING**] Remove `PartialEq` impl for `&Atom`
(#8642 ) (overlookmotel)
### Features
- 2a2ad53 allocator: Add `Allocator::capacity` and `used_bytes` methods
(#8621 ) (overlookmotel)
- 6801c81 allocator: Add `Allocator::new` and `with_capacity` methods
(#8620 ) (overlookmotel)
- 99607d3 codegen: Print comments in `TSTypeLiteral` (#8679 ) (Boshen)
- 4ae568e linter: Add DiagnosticResult to the Reporters for receiving a
sub part result (#8666 ) (Alexander S.)
- 343690e minifier: Replace `Number.*_SAFE_INTEGER`/`Number.EPSILON`
(#8682 ) (sapphi-red)
- 0c5bb30 minifier: Replace
`Number.POSITIVE_INFINITY`/`Number.NEGATIVE_INFINITY`/`Number.NaN`
(#8681 ) (sapphi-red)
- 835b258 minifier: Compress `typeof foo === 'object' && foo !== null`
to `typeof foo == 'object' && !!foo` (#8638 ) (sapphi-red)
- 2bcbed2 minifier: Compress `(a = b) === null || a === undefined` to
`(a = b) == null` (#8637 ) (sapphi-red)
### Bug Fixes
- 40316af linter: Fix github `endColumn` output (#8647 ) (Alexander S.)
- 883d25b minifier: Keep esm in dce (#8677 ) (Boshen)
- 878ce10 minifier: `void 0` equals to `undefined` (#8673 ) (Boshen)
- ba201a6 minifier: Remove "non esbuild optimizations" which is
incorrect (#8668 ) (Boshen)
- 8c8b5fa minifier: Avoid minifing `String(a)` into `"" + a` for symbols
(#8612 ) (翠 / green)
- 4ff6e85 minifier: Remove expression statement `void 0` (#8602 )
(Boshen)
- 93d643e minifier: Keep side effects when folding const conditional
exprs (#8591 ) (camc314)
- 178c232 parser: Parse `intrinsic` TS keyword (#8627 ) (Kevin Deng 三咲智子)
- 48717ab parser: Parse `true` as `TSLiteralType` (#8626 ) (Kevin Deng
三咲智子)
- d1c5dc4 semantic: Fix const assertions in `UnresolvedReferencesStack`
(#8653 ) (overlookmotel)
### Performance
- 787aaad allocator: Make `String` non-drop (#8617 ) (overlookmotel)
- d966e0a codegen: Do not check for comments if turned off (#8598 )
(Boshen)
- 3fa87ff lexer: Peak 2 bytes after `!` (#8662 ) (Boshen)
- 9953ac7 minifier: Add `LatePeepholeOptimizations` (#8651 ) (Boshen)
- 00dc63f minifier: Only substitute typed array constructor once (#8649 )
(Boshen)
- 3e19e4e minifier: Remove the useless empty statement removal code in
statement fusion (#8646 ) (Boshen)
- 5b3c412 minifier: Only run optimizations on local changes (#8644 )
(Boshen)
### Documentation
- c1d243b allocator: Improve docs for `Allocator` (#8623 )
(overlookmotel)
- 01a5e5d allocator: Improve docs for `HashMap` (#8616 ) (overlookmotel)
- 87568a1 allocator: Reformat docs (#8615 ) (overlookmotel)
- 3be0392 lexer: Fix doc comment (#8664 ) (overlookmotel)
- 5029547 semantic: Fix and reformat doc comments (#8652 )
(overlookmotel)
### Refactor
- ae8db53 allocator: Move `Allocator` into own module (#8656 )
(overlookmotel)
- 0f85bc6 allocator: Reduce repeat code to prevent `Drop` types in arena
(#8655 ) (overlookmotel)
- de76eb1 allocator: Reorder `Box` methods (#8654 ) (overlookmotel)
- 997859c ast: Align `#[estree(via)]` behavior (#8599 ) (sapphi-red)
- db863a3 codegen: Use `Stack` for `binary_expr_stack` (#8663 ) (Boshen)
- 8cce69a codegen: Remove `match_member_expression` (#8597 ) (Boshen)
- a3dc4c3 crates: Clean up snapshot files (#8680 ) (Boshen)
- e66da9f isolated_declarations, linter, minifier, prettier, semantic,
transformer: Remove unnecessary `ref` / `ref mut` syntax (#8643 )
(overlookmotel)
- 23b49a6 linter: Use `cow_to_ascii_lowercase` instead
`cow_to_lowercase` (#8678 ) (Boshen)
- ce2b9da minifier: Remove `wrap_to_avoid_ambiguous_else` (#8676 )
(Boshen)
- 75a579b minifier: Clean up
`has_no_side_effect_for_evaluation_same_target` (#8675 ) (Boshen)
- 1bb2539 minifier: Move more code into `minimize_conditions` local loop
(#8671 ) (Boshen)
- 13e4a45 minifier: Move conditional assignment to `minimize_conditions`
(#8669 ) (Boshen)
- ae895d8 minifier: Use `NonEmptyStack` for function stack (#8661 )
(Boshen)
- 3802d28 minifier: Clean up `try_minimize_conditional` (#8660 ) (Boshen)
- dcc1f2b minifier: Rename `ast_passes` to `peephole` (#8635 ) (Boshen)
- 52458de minifier: Remove unused code and traits (#8632 ) (Boshen)
- 6f95cd5 minifier: Remove all the unnecessary fake ast passes (#8618 )
(Boshen)
- 712cae0 minifier: Run the compressor on all test cases (#8604 )
(Boshen)
- 864b8ef parser: Shorten code (#8640 ) (overlookmotel)
- b8d9a51 span: Deal only in owned `Atom`s (#8641 ) (overlookmotel)
- 20f52b1 span: Remove unnecessary lifetimes on `Atom` impls (#8639 )
(overlookmotel)
- ac4f98e span: Derive `Copy` on `Atom` (#8596 ) (branchseer)
- a730f99 transformer: Move `create_prototype_member` to utils module
(#8657 ) (Dunqing)
- 61d96fd transformer/class-properties: Correct comments (#8636 )
(overlookmotel)
### Testing
- 39dbd2d codegen: Fix snapshot file (#8685 ) (Boshen)
- d9f5e7f minifier: Enable passed esbuild tests (Boshen)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com >
2025-01-24 12:09:37 +08:00
oxc-bot
8f5be07ed6
release(crates): v0.47.1 ( #8593 )
...
## [0.47.1] - 2025-01-19
### Features
- ee8ee55 napi/parser: Add `.hasChanged()` to `MagicString` (#8586 )
(Boshen)
- 1bef911 napi/parser: Add source map API (#8584 ) (Boshen)
### Bug Fixes
- 7b219a9 minifier: Fix dce shadowed undefined (#8582 ) (Boshen)
- 7421a52 transformer/typescript: Correctly resolve references to
non-constant enum members (#8543 ) (branchseer)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com >
2025-01-19 09:44:29 +08:00
Boshen
ee8ee55cda
feat(napi/parser): add .hasChanged() to MagicString ( #8586 )
2025-01-18 15:29:17 +00:00
Boshen
1bef911e59
feat(napi/parser): add source map API ( #8584 )
2025-01-18 23:06:42 +08:00
oxc-bot
d3fd7a9741
release(crates): v0.47.0 ( #8580 )
...
## [0.47.0] - 2025-01-18
- fae4cd2 allocator: [**BREAKING**] Remove `Vec::into_string` (#8571 )
(overlookmotel)
- 95bc0d7 allocator: [**BREAKING**] `Allocator` do not deref to
`bumpalo::Bump` (#8569 ) (overlookmotel)
- 19d3677 ast: [**BREAKING**] Always return
`Array<ImportDeclarationSpecifier>` for `ImportDeclaration.specifiers`
(#8560 ) (sapphi-red)
- 4ce6329 semantic: [**BREAKING**] Ensure program outlives semantic
(#8455 ) (Valentinas Janeiko)
- 7066d1c ast, span, syntax, regular_expression: [**BREAKING**] Remove
`ContentHash` (#8512 ) (overlookmotel)
### Features
- bf4e5e1 allocator: Add `HashMap` (#8553 ) (overlookmotel)
- a6d71f8 ast: Add `AstKind::ty` method (#8521 ) (overlookmotel)
- 4d4e805 minifier: Collapse if stmt with empty consequent (#8577 )
(camc314)
- 991a22f minifier: Fold `Array::concat` into literal (#8442 )
(sapphi-red)
- 3dc2d8b minifier: Fold string concat chaining (#8441 ) (sapphi-red)
- a4ae450 minifier: Fold array concat chaining (#8440 ) (sapphi-red)
- 7cc81ef minifier: Fold invalid typeof comparisons (#8550 ) (camc314)
- 927f43f minifier: Improve `.charCodeAt(arg)` when arg is valid (#8534 )
(Boshen)
- 06f14d5 minifier: Remove empty class static block `class Foo { static
{} }` (#8525 ) (Boshen)
- 1860411 minifier: Remove last redundant return statement (#8523 )
(Boshen)
- c479a58 napi/parser: Expose dynamic import expressions (#8540 )
(Boshen)
- 2f0314e npm/oxc-minify: Npm package and publish script (#8579 )
(Boshen)
- f413bb5 transformer/optional-chaining: Change parent scope for
expression when it wrapped with an arrow function (#8511 ) (Dunqing)
### Bug Fixes
- e87c001 allocator: Statically prevent memory leaks in allocator
(#8570 ) (overlookmotel)
- 855c839 codegen: Shorthand assignment target identifier consider
mangled names (#8536 ) (Boshen)
- 65c596d minifer: Keep idents if not in scope when minimizing array
exprs (#8551 ) (camc314)
- f57aac2 minifier: Incorrect folding of expr in bool ctx (#8542 )
(camc314)
- 946ad76 minifier: `(-Infinity).toString()` -> `'-Infinity'` (#8535 )
(Boshen)
- b1d0186 minifier: Do not fold `!!void b` (#8533 ) (Boshen)
- 53adde5 minifier: `x['-2147483648']` -> `x[-2147483648]` (#8528 )
(Boshen)
- 405b73d minifier: Do not change `delete undefined` to `delete void 0`
(#8527 ) (Boshen)
- 92e44cb minifier: Do not remove `undefined` in `var x = undefined`
(#8526 ) (Boshen)
- 209e313 minifier: `class C { ['-1']() {} }` cannot be minifized
(#8516 ) (Boshen)
- 6585463 minifier: Always keep the last value of sequence expression
(#8490 ) (Boshen)
- b552f5c transformer: `wrap_in_arrow_function_iife` take span of input
`Expression` (#8547 ) (overlookmotel)
- 9963533 transformer/arrow-functions: Visit arguments to `super()` call
(#8494 ) (overlookmotel)
- 06ccb51 transformer/async-to-generator: Move parameters to the inner
generator function when they could throw errors (#8500 ) (Dunqing)
- 356f0c1 transformer/class-properties: Handle nested `super()` calls
(#8506 ) (overlookmotel)
- a048337 transformer/class-static-blocks: Static block converted to
IIFE use span of original block (#8549 ) (overlookmotel)
### Performance
- 76ea52b allocator: Inline `Box` methods (#8572 ) (overlookmotel)
- 93df57f allocator: `#[inline(always)]` methods of `Vec` which just
delegate to `allocator_api2` (#8567 ) (overlookmotel)
- 5a28d68 allocator: `#[inline(always)]` methods of `HashMap` which just
delegate to `hashbrown` (#8565 ) (overlookmotel)
- d17021c mangler: Optimize `base54` function (#8557 ) (overlookmotel)
- 6b52d7a mangler: Use a single allocation space for temporary vecs
(#8495 ) (Boshen)
- 30a869e semantic: Use `oxc_allocator::HashMap` in `ScopeTree` (#8554 )
(overlookmotel)
- 63eb298 span: Compare `Span`s as single `u64`s (#8300 ) (overlookmotel)
- a43560c span: Hash `Span` as a single `u64` (#8299 ) (overlookmotel)
- 3fff7d2 span: Align `Span` same as `usize` (#8298 ) (overlookmotel)
- 53ef263 transformer/arrow-functions: Bail out of visiting early when
inserting `_this = this` after `super()` (#8482 ) (overlookmotel)
### Documentation
- fa1a6d5 allocator: Update docs for `Vec` (#8555 ) (overlookmotel)
### Refactor
- ac05134 allocator: `String` type (#8568 ) (overlookmotel)
- 68fab81 allocator: Rename inner `Vec` type (#8566 ) (overlookmotel)
- fcbca32 ast: Rename `#[estree(with)]` to `#[estree(via)]` (#8564 )
(overlookmotel)
- 007e8c0 ast, regular_expression: Shorten `ContentEq` implementations
(#8519 ) (overlookmotel)
- b4c87e2 linter: Move DiagnosticsReporters to oxlint (#8454 ) (Alexander
S.)
- 8f57929 minifier: Merge `try_compress_type_of_equal_string` into
`try_minimize_binary` (#8561 ) (sapphi-red)
- 2857ae1 parser: Refactor visitor in regexp example (#8524 )
(overlookmotel)
- b5ed58e span: All methods take owned `Span` (#8297 ) (overlookmotel)
- 712633f transformer: `wrap_statements_in_arrow_function_iife` utility
function (#8548 ) (overlookmotel)
- 5206c6a transformer: Rename `wrap_in_arrow_function_iife` (#8546 )
(overlookmotel)
- 61077ca transformer: `wrap_arrow_function_iife` receive an owned
`Expression` (#8545 ) (overlookmotel)
- 6820d24 transformer: Move `wrap_arrow_function_iife` to root utils
module (#8529 ) (Dunqing)
- 52bd0b1 transformer: Move common utils functions to the root module
(#8513 ) (Dunqing)
- c30654a transformer/arrow-function: Wrapping arrow function iife by
using `wrap_arrow_function_iife` (#8530 ) (Dunqing)
- 2bc5175 transformer/arrow-functions: Rename method (#8481 )
(overlookmotel)
- 72f425f transformer/class-properties: Fix lint warning in release mode
(#8539 ) (overlookmotel)
- 7e61b23 transformer/typescript: Shorten code (#8504 ) (overlookmotel)
- 04bc259 traverse: Remove unnecessary `#[allow]` (#8518 )
(overlookmotel)
- a368726 traverse: Harden soundness of `Traverse` and document safety
invariants better (#8507 ) (overlookmotel)
### Testing
- e0f5d6c minifier: Update esbuild test (Boshen)
- 629c417 minifier: Port esbuild minification tests (#8497 ) (Boshen)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com >
2025-01-18 14:26:20 +08:00
Boshen
c479a58718
feat(napi/parser): expose dynamic import expressions ( #8540 )
...
closes #8369
2025-01-16 22:25:22 +08:00
Boshen
aa9d7e47ea
build(napi): napi build --no-dts-cache ( #8499 )
2025-01-15 07:02:29 +00:00
oxc-bot
3e05055783
release(crates): v0.46.0 ( #8487 )
...
## [0.46.0] - 2025-01-14
- 7eb6ccd ast: [**BREAKING**] Remove unused and not useful `ContentHash`
(#8483 ) (Boshen)
### Features
- 8accfef minifier: Minify `var x; void x` -> `void 0` (#8466 ) (Boshen)
- 870a583 minifier: Fold `false['toString']` (#8447 ) (Boshen)
- 4ad695d napi/minify: Implement napi (#8478 ) (Boshen)
- 9d550aa span: Add `Atom::r#static` (#8479 ) (_Kerman)
### Bug Fixes
- 4071878 isolated-declarations: Retain `declare` declarations when they
are exported (#8477 ) (Dunqing)
- 7ee7634 isolated-declarations: Import statement disappears when import
binding is referenced in nested `typeof` (#8476 ) (Dunqing)
- 7252cb0 isolated-declarations: Unexpected error when global `Symbol`
as property key (#8475 ) (Dunqing)
- 4c6675c minifier: Do not convert while to fors in DCE (#8484 ) (Boshen)
- 1d6e84d minifier: Fix incorrect `null.toString()` and `1n.toString()`
(#8464 ) (Boshen)
- 25d4bf9 minifier: Remove usage of empty spans (#8462 ) (Boshen)
- dd64340 minifier: Keep `return undefined` in async generator function
(#8439 ) (Boshen)
- c444de8 transformer/arrow-functions: Transform `this` and `super`
incorrectly in async arrow function (#8435 ) (Dunqing)
- 270245f transformer/typescript: Correct the semantic for
TSImportEqualsDeclaration transformation (#8463 ) (Dunqing)
- 2a400d6 transformer/typescript: Retain TSImportEqualsDeclaration when
it is exported (Dunqing)
- ab694b0 transformer/typescript: Retain `TSImportEqualsDeclaration` in
`namespace` when its binding has been referenced or
`onlyRemoveTypeImports` is true (#8458 ) (Dunqing)
### Performance
- 7a8200c mangler: Allocate base54 name without heap allocation (#8472 )
(Boshen)
- 31dac22 mangler: Allocate data in arena (#8471 ) (Boshen)
- 8fc238a minifier: Merge `Normalize` and `RemoveSyntax` pass (#8467 )
(Boshen)
- 372eb09 minifier: Preallocate mangler's semantic data (#8451 ) (Boshen)
### Refactor
- 6e64eef codegen: Remove `match_expression!` (#8450 ) (Boshen)
- de5b288 span: Rename `Atom::new_const` method (#8480 ) (overlookmotel)
- c83ce5c transformer/typescript: Improve transforming namespace (#8459 )
(Dunqing)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com >
2025-01-14 19:40:44 +08:00
oxc-bot
01722f34ff
release(crates): v0.45.0 ( #8434 )
...
## [0.45.0] - 2025-01-11
- 7f69561 ast: [**BREAKING**] `oxc_ast` do not export `BigUint` (#8428 )
(overlookmotel)
- d8b27af ast: [**BREAKING**] No unneccesary trailing underscores on
`AstBuilder` method names (#8283 ) (overlookmotel)
- 5106088 ast: [**BREAKING**] Remove `FromIn<Expression> for Statement`
(#8280 ) (overlookmotel)
### Features
- 6c7acac allocator: Implement `IntoIterator` for `&mut Vec` (#8389 )
(overlookmotel)
- 3212bcd ast_tools: Ignore `raw` field of `NumericLiteral` and
`StringLiteral` in `ContentEq` (#8417 ) (Boshen)
- ad146bb codegen: Print real newline when `\n` is inside template
literals (#8178 ) (Boshen)
- 41ddf60 minfier: Add `CompressOptions::target` (#8179 ) (Boshen)
- d56020b minifier: Drop `0` from `new Int8Array(0)` and other
TypedArrays (#8431 ) (sapphi-red)
- f935d94 minifier: Remove `new` from NativeErrors / `AggregateError`
(#8430 ) (sapphi-red)
- dab7a51 minifier: Minimize not `!(x === undefined)` -> `x !==
undefined` (#8429 ) (Boshen)
- 0e7bab8 minifier: Remove `if(false){}` in a single pass (#8421 )
(Boshen)
- 5b5b844 minifier: Fold `ambiguous if else` (#8415 ) (Boshen)
- 438a6e7 minifier: Minimize conditions in boolean context (#8381 )
(Boshen)
- 793cb43 minifier: `a != null ? a : b` -> `a ?? b` (#8352 ) (camc314)
- 814da55 minifier: Compress `x = x || 1` to `x ||= 1` (#8368 )
(sapphi-red)
- a596821 minifier: Compress `a.b = a.b + c` to `a.b += c` (#8367 )
(sapphi-red)
- 579eb60 minifier: Compress `a.b || (a.b = c)` to `a.b ||= c` (#8366 )
(sapphi-red)
- f367a16 minifier: Port esbuild conditional expr minification (#8351 )
(camc314)
- 8d52cd0 minifier: Merge assign expression in conditional expression
(#8345 ) (sapphi-red)
- a69d15f minifier: Compress `new Array(2)` -> `[,,]` (#8344 )
(sapphi-red)
- 819c475 minifier: Compress `new Array(7n)` -> `[7n]` (#8343 )
(sapphi-red)
- e085d66 minifier: Remove empty IIFE (#8340 ) (Boshen)
- 2c2e483 minifier: Fold object spread `({ ...null })` -> `({})` (#8339 )
(Boshen)
- 6220e05 minifier: Remove empty if statment `if (test) {}` -> `test`
(#8336 ) (Boshen)
- a76dfae minifier: Remove label statement with empty body (#8333 )
(Boshen)
- e88a6bd minifier: Minimize `!0 + null !== 1` -> `!0 + null != 1`
(#8332 ) (Boshen)
- ec88c68 minifier: Compress `a || (a = b)` to `a ||= b` (#8315 )
(sapphi-red)
- e6fe84d minifier: Compress `a = a + b` to `a += b` (#8314 )
(sapphi-red)
- 9ea4e31 minifier: Remove `new` from `new Error`/`new Function`/`new
RegExp` (#8313 ) (sapphi-red)
- 051fbb6 minifier: Minimize `x["0"]` -> x[0] (#8316 ) (Boshen)
- a542013 minifier: Minimize `do{}while(true)` -> `do;while(true)`
(#8311 ) (Boshen)
- e3ff81e minifier: Minimize `(x = 1) === 1` -> `(x = 1) == 1` (#8310 )
(Boshen)
- 4b68cc0 minifier: Minimize empty `try` statement (#8309 ) (Boshen)
- 922c514 minifier: Fold `.toString()` (#8308 ) (Boshen)
- 66a2443 minifier: Minify sequence expressions (#8305 ) (camc314)
- af65c36 minifier: Minimize double negated binary expressions (#8304 )
(camc314)
- 76c778b minifier: Remove logical nots when arg is a delete expression
(#8303 ) (camc314)
- 5ed439b minifier: Minify typeof in binary expressions (#8302 )
(camc314)
- 6afc590 minifier: Compress typeof addition string (#8301 ) (camc314)
- ecc789f minifier: Fold `if(x >> y == 0){}` -> `if(!(x >> y)){}`
(#8277 ) (Boshen)
- 0e3b79a minifier: Fold `String()` -> `''`, `Number()` -> `false`
(#8274 ) (Boshen)
- c9cf593 minifier: Compress property key `{[1]: _}` -> {1: _} (#8272 )
(Boshen)
- b92b2ab minifier: Fold `BigInt(1n)` -> `1n` (#8270 ) (Boshen)
- a4df387 minifier: Compress loose equals undefined (#8268 ) (camc314)
- f000596 minifier: Minify call expressionsto `Number` (#8267 ) (camc314)
- 092aeaf minifier: Flatten spread args in call expressions (#8266 )
(camc314)
- 04ec38d minifier: Remove unused arrow function expressions (#8262 )
(camc314)
- e446c15 minifier: Improve minimizing unary not expressions (#8261 )
(camc314)
- 7f19211 minifier: Minimize unary expression statements (#8256 )
(camc314)
- cec63e2 minifier: `{}` evals to `f64::NaN` (Boshen)
- 4d8a08d minifier: Improve constant evaluation (#8252 ) (Boshen)
- e84f267 minifier: Compress more property keys (#8253 ) (Boshen)
- d1224f9 minifier: Improve minimizing conditional expressions (#8251 )
(camc314)
- 65f46f5 minifier: Constant fold `String.fromCharCode` (#8248 ) (Boshen)
- bd8d677 minifier: Minimize `~undefined`, `~null`, `~true`, `~false`
(#8247 ) (Boshen)
- f73dc9e minifier: Constant fold `'x'.toString()` and `true.toString()`
(#8246 ) (Boshen)
- fd5af73 minifier: Minimize `Number` constructor (#8245 ) (Boshen)
- 2f52f33 minifier: Minsize `!!!foo ? bar : baz` -> `foo ? baz : bar`
(#8244 ) (Boshen)
- ccdc039 minifier: Always put literals on the rhs of equal op `1==x` =>
`x==1` (#8240 ) (Boshen)
- 39353b2 minifier: Improve minimizing conditionals (#8238 ) (Cameron)
- c90fc16 minifier: Restore conditional minification and fix edge case
(#8235 ) (camc314)
- 6c8ee9f minifier: Remove last redundant `return` statement (#8234 )
(Boshen)
- 51f4792 minifier: Minimize `foo ? foo : bar` and `foo ? bar : foo`
(#8229 ) (Boshen)
- 6e2ec17 minifier: Statement fusion switch cases; improved minimize
exit poitns (#8228 ) (Boshen)
- 574a242 minifier: Minimize all variants of `typeof x == 'undefined'`
(#8227 ) (Boshen)
- 2041477 minifier: Fold `if(x)return;y` -> `if(!x)y` (#8226 ) (Boshen)
- 9c1afa4 minifier: Optional catch binding when catch param is unused
(#8221 ) (Boshen)
- 4a29845 minifier: Add `ConvertToDottedProperties` (#8212 ) (Boshen)
- 2786dea minifier: Add `RemoveUnusedCode` (#8210 ) (Boshen)
- cd274ee minifier: Minimize logical exprs (#8209 ) (Cameron)
- 4ae15df minifier: Imprve more conditional expr minification with
boolean lit (#8208 ) (camc314)
- 3202b4f minifier: Imprve conditional expr minification with boolean
lit (#8207 ) (camc314)
- 3b45011 minifier: Handle conditional expr with boolean lit (#8206 )
(camc314)
- 4c2059a minifier: Reverse negated conditional exprs (#8205 ) (camc314)
- 4804933 minifier: Add `MinimizeExitPoints` and ExploitAssigns`
boilerplate (#8203 ) (Boshen)
- bf266e1 minifier: Try collapse conditional to logical or expr (#8197 )
(Cameron)
- 06e1780 minifier: Improve `StatementFusion` (#8194 ) (Boshen)
- 42e211a minifier: Only constant fold numbers when result is smaller
(#8092 ) (Boshen)
- d0de560 minifier: Change `NaN` to `f64::NAN` (#8191 ) (Boshen)
- cef8eb8 minifier: Change `foo?.['bar']` to `foo?.bar` (#8176 ) (翠 /
green)
- 8149e34 minifier: Optional catch binding when es target >= es2019
(#8180 ) (Boshen)
- fc43ec5 minifier: Fold `string.length` / `array.length` (#8172 )
(sapphi-red)
- 29dc0dc minifier: Change `foo['bar']` -> foo.bar (#8169 ) (Boshen)
- 3c5718d minifier: Fold `typeof foo == undefined` into `foo ==
undefined` when possible (#8160 ) (翠 / green)
- f3a36e1 minifier: Fold `typeof foo != "undefined"` into `typeof foo <
"u"` (#8159 ) (翠 / green)
- 37c9959 minifier: Normalize `Infinity` into `f64::Infinity` (#8148 )
(Boshen)
- 8fb71f5 minifier: Minify string `PropertyKey` (#8147 ) (Boshen)
- 6615e1e minifier: Constant fold `instanceof` (#8142 ) (翠 / green)
- 2b2a373 minifier: Minimize `a + 'b' + 'c'` -> `a + 'bc'` (#8137 )
(Boshen)
- 213364a minifier: Minimize `if (x) if (y) z` -> `if (x && y) z`
(#8136 ) (Boshen)
- 6b51e6d minifier: Minimize `if(foo) bar else baz` -> `foo ? bar : baz`
(#8133 ) (Boshen)
- f615bfa minifier: Minimize `if (x) return; return 1` -> `return x ?
void 0 : 1` (#8130 ) (Boshen)
- f0b1ee5 minifier: Minimize `if(!x) foo()` -> `x || foo()` (#8122 )
(Boshen)
- f8200a8 minifier: Minimize `if(foo) bar` -> `foo && bar` (#8121 )
(Boshen)
- 72d9967 minifier: Add `Normalize` ast pass (#8120 ) (Boshen)
- fef0b25 minifier: Collapse `var` into for loop initializer (#8119 )
(Boshen)
- 2331ea8 minifier: `typeof foo === 'number'` => `typeof foo ==
'number'` (#8112 ) (Boshen)
- ad9a0a9 mininifier: Minimize variants of `a instanceof b == true`
(#8241 ) (Boshen)
- 2da4365 parser: Missing initializer in destructuring declaration
inside for loop head (#8222 ) (Boshen)
- 55744fd semantic: Allow getting mutable reference to symbols table
(#8189 ) (Max Stoumen)
- 0592a8b transformer/class-properties: Transform private in expression
(#8202 ) (Dunqing)
- ad77ad5 transformer/class-properties: Transform static/instance
accessor methods (#8132 ) (Dunqing)
- e405f79 transformer/class-properties: Transform static private method
invoking (#8117 ) (Dunqing)
- 3303e99 transformer/class-properties: Insert statements after
statement of class expression (#8116 ) (Dunqing)
- 0cc71cf transformer/class-properties: Transform super expressions and
identifiers that refers to class binding in private method (#8106 )
(Dunqing)
- 58ed832 transformer/class-properties: Transform private field
expression which invokes private method (#8102 ) (Dunqing)
- f14567a transformer/class-properties: Transform callee which invokes
private method (#8100 ) (Dunqing)
- 13349ef transformer/class-properties: Transform private methods
(#8099 ) (Dunqing)
### Bug Fixes
- eb25bc0 allocator: Fix lifetimes on `IntoIterator` for `Vec` (#8388 )
(overlookmotel)
- 97a7992 ast: Fix `ContentEq` and `ContentHash` impls for literal types
(#8426 ) (overlookmotel)
- a1752a0 codegen: Fix incorrect minified `return 1n` output (#8374 )
(Boshen)
- 5a648bc codegen: Fix white space issue with do statements (#8348 )
(Boshen)
- b6d16f4 codegen: Print parenthesis on negative bigint lit when
neccessary (#8258 ) (camc314)
- 8ed9766 codegen: Source map builder panicked because it attempted to
subtract with overflow in `search_original_line_and_column` (#8185 )
(Dunqing)
- ad61e70 codegen: Print if else without block with proper indentation
(#8135 ) (Boshen)
- 74572de ecmascript: Incorrect `to_int_32` value for Infinity (#8144 )
(翠 / green)
- e1f8ea4 lexer: `Source` is not `Clone` (#8294 ) (overlookmotel)
- 5c63414 mangler: Keep exported symbols for `top_level: true` (#7927 )
(翠 / green)
- 3c93549 minifier: Dce if statement should keep side effects and vars
(#8433 ) (Boshen)
- 52f88c0 minifier: Rotate associative operators to make it more
idempotent (#8424 ) (camc314)
- a80460c minifier: Correctly set `self.changed` when minimizing if
stmts (#8420 ) (camc314)
- d4ca8d4 minifier: `!!x` is not idempotent in `RemoveDeadCode` (#8419 )
(Boshen)
- 357b61d minifier: Do not minify `Object.defineProperty` in sequence
expressions (#8416 ) (Boshen)
- 0efc845 minifier: `+0n` produces `TypeError` (#8410 ) (Boshen)
- 7ce6a7c minifier: `a in b` has error throwing side effect (#8406 )
(Boshen)
- 2f3a9dc minifier: Cannot transform property key `#constructor` (#8405 )
(Boshen)
- c0a3dda minifier: `instanceof` has error throwing side effect (#8378 )
(Boshen)
- 5516f7f minifier: Do not fold object comparisons (#8375 ) (Boshen)
- cb098c7 minifier: Computed property key `prototype` cannot be changed
(#8373 ) (Boshen)
- 82ee77e minifier: Do not remove shadowned `undefined` in return
statement (#8371 ) (Boshen)
- f87da16 minifier: Do not fold literals in `-0 != +0` (#8278 ) (Boshen)
- 62a2644 minifier: Handle arrow fn expressions correctly in
`is_in_boolean_context` (#8260 ) (camc314)
- d2f8eaa minifier: Fix panic in `peephole_minimize_conditions` (#8242 )
(Boshen)
- a698def minifier: Fix incorrect return value for `(x ? true : y)`
(#8233 ) (Boshen)
- 05be1fc minifier: Remove incorrect fold
`Expression::AssignmentExpression` (#8211 ) (Boshen)
- 56b7f13 minifier: Do not constant fold `0 instanceof F` (#8199 )
(Boshen)
- 75d5f17 minifier: Minify string `PropertyKey` (#8177 ) (sapphi-red)
- f88acb3 parser: Allow line breaks between `const` and `enum` (#8193 )
(branchseer)
- 79a8fc6 semantic: Report error for super property appearing in
function body (#8376 ) (Dunqing)
- 79af100 semantic: Reference flags not correctly resolved when after an
export stmt (#8134 ) (camc314)
- 3eaff2a transformer: Ensure last expression statement in arrow
function expression is wrapped in return (#8192 ) (Dunqing)
- 3feac27 transformer/arrow-functions: Outer `super()` in nested class
(#8382 ) (Dunqing)
- 335065d transformer/arrow-functions: Do not transform super that
inside nested non-async method (#8335 ) (Dunqing)
- e4d66e4 transformer/arrow-functions: Store `super_methods` on a
`Stack` to fix nested async methods (#8331 ) (Dunqing)
- 775a289 transformer/arrow-functions: `_this = this` should be inserted
after super call expression (#8024 ) (Dunqing)
- ac72adb transformer/private-methods: Fix panic if instance private
accessor in class (#8362 ) (overlookmotel)
- f1f129b transformer/private-methods: Create brand binding `var` in
hoist scope (#8361 ) (overlookmotel)
- ab61425 transformer/private-methods: No temp var for class when unused
private methods (#8360 ) (overlookmotel)
- 9a03bd2 transformer/typescript: Remove type-only `import =` when
`only_remove_type_imports` is true (#8275 ) (Dunqing)
- 0df1866 transformer/typescript: Create `Reference` for `require`
(#8355 ) (overlookmotel)
- 78d7c97 transformer/typescript: Create `Reference` for `Infinity`
(#8354 ) (overlookmotel)
- 2e7207f transformer/typescript: Should strip import specifiers type
with `only_remove_type_imports` (#8141 ) (underfin)
### Performance
- 07edf74 transformer/arrow-function: Stop traversal at function as
super() can't appear in a nested function (#8383 ) (Dunqing)
- 62e3f7e transformer/arrow-functions: Reduce size of inlined visitor
(#8322 ) (overlookmotel)
- aebe0ea transformer/arrow-functions: Use `NonEmptyStack` instead of
`Stack` (#8318 ) (overlookmotel)
### Documentation
- c8e4843 ast: Fix doc comment (#8286 ) (overlookmotel)
- e0a09ab data_structures: Improve docs for stack types (#8356 )
(overlookmotel)
- aaa009d minifier: Clarify assumptions for compressor (#8404 ) (翠 /
green)
- 05cba5b transformer/private-methods: Amend comments (#8398 )
(overlookmotel)
### Refactor
- b29655f ast: Rearrange impls for literal types in same order as they
are defined (#8425 ) (overlookmotel)
- 0db2a22 ast: `AstBuilder` enum builder methods use `alloc_*` methods
(#8281 ) (overlookmotel)
- aea9551 ast: Simplify `get_identifier_reference` of `TSType` and
`TSTypeName` (#8273 ) (Dunqing)
- 9c1844a data_structures: Remove `NonNull` shim (#8423 ) (overlookmotel)
- 1835687 ecmascript: Remove unnecessary `use` statement (#8284 )
(overlookmotel)
- 64bfdfe lexer: Tighten safety of lexer by always including lifetime on
`SourcePosition` (#8293 ) (overlookmotel)
- 0344e98 lexer: Make `handle_byte` a method of `Lexer` (#8291 )
(overlookmotel)
- fabf116 lexer: Replace `#[allow]` with `#[expect]` (#8289 )
(overlookmotel)
- 0462edb lexer: Rename function param (#8288 ) (overlookmotel)
- fb2acd8 minifier: Change minimize conditionals into a loop (#8413 )
(Boshen)
- baaec60 minifier: Remove the buggy `??` transform (#8411 ) (Boshen)
- 1c4658d minifier: Change ast passes order, `!in_fixed_loop` happen
last (#8380 ) (Boshen)
- 09f0f48 minifier: Remove the buggy `minimize_exit_points`
implementation (#8349 ) (Boshen)
- 9a5c66a minifier: Clean up (#8346 ) (Boshen)
- 98f2b1c minifier: Clean up `peephole_substitute_alternate_syntax`
(#8327 ) (Boshen)
- fc662b7 minifier: Handle big int values later (#8324 ) (Boshen)
- d16e598 minifier: Clean up `peephole_replace_known_methods` (#8306 )
(Boshen)
- b8d26ea minifier: Move optional catch param to
peephole_substitute_alternate_syntax (#8282 ) (Boshen)
- 0845162 minifier: Clean up `ReplaceKnownMethods` (Boshen)
- 7c7f5d7 minifier: Clean up `peephole_fold_constants` (Boshen)
- bf0fbce minifier: Improve constant fold numbers (#8239 ) (Boshen)
- 62f8fba minifier: Move all conditional minification logic to
minimze_conditions (#8231 ) (camc314)
- cfb51f2 minifier: Fuse ast passes (#8184 ) (Boshen)
- bf9cafe minifier: Clean up `peephole_substitute_alternate_syntax` a
little bit (Boshen)
- 75264ed minifier: Clean up `try_optimize_block` (#8139 ) (Boshen)
- c22062b minifier: Cleanup peephole_minimize_conditions (#8114 )
(Boshen)
- e594c39 minifier: Clean up `peephole_substitute_alternate_syntax.rs`
(#8111 ) (Boshen)
- 0903501 semantic: Check super usage based on scope (#8377 ) (Dunqing)
- 109b8fc transformer: Elide lifetimes where possible (#8285 )
(overlookmotel)
- fb389f7 transformer/arrow-function: Create a new ident instead of
clone (#8338 ) (Dunqing)
- dddbd29 transformer/arrow-functions: Reorder assertions (#8386 )
(overlookmotel)
- ce6c445 transformer/arrow-functions: Add TODO comments (#8328 )
(overlookmotel)
- 73d0025 transformer/arrow-functions: Reduce repeated code (#8323 )
(overlookmotel)
- 3dd08e9 transformer/arrow-functions: Do not inline non-trivial visitor
method (#8321 ) (overlookmotel)
- ea9cefb transformer/arrow-functions: Reorder visitor methods (#8320 )
(overlookmotel)
- 37199a4 transformer/arrow-functions: Rename lifetime (#8319 )
(overlookmotel)
- 57e9dcf transformer/arrow-functions: Shorten `AstBuilder` call (#8317 )
(overlookmotel)
- a5e3528 transformer/async-to-generator: Pass `TraverseCtx` to function
not `AstBuilder` (#8279 ) (overlookmotel)
- e7c89ba transformer/class-properties: TODO comments (#8392 )
(overlookmotel)
- 6790d1d transformer/class-properties: Simplify determining if class is
declaration (#8357 ) (overlookmotel)
- c786a13 transformer/class-properties: Share
`replace_class_name_with_temp_var` in class_properties (#8105 ) (Dunqing)
- f54f48e transformer/class-properties: Remove all `*_if_super` methods
in `static_block_and_prop_init` (#8104 ) (Dunqing)
- d82fb52 transformer/class-properties: Move `supers` to
`super_converter` (#8103 ) (Dunqing)
- 3dad85e transformer/private-methods: Remove unnecessary clone (#8400 )
(overlookmotel)
- aa5e65f transformer/private-methods: Simplify finding parent statement
of class expression (#8364 ) (overlookmotel)
- c786fd1 transformer/private-methods: TODO comments (#8363 )
(overlookmotel)
### Styling
- 4d2888d lexer: Reorder imports (#8290 ) (overlookmotel)
- e81f34f span: Reformat code (#8296 ) (overlookmotel)
- 45e2402 transformer/private-methods: Move comments (#8399 )
(overlookmotel)
- 0a1ffc0 transformer/private-methods: Rename var (#8397 )
(overlookmotel)
### Testing
- 16dcdaf lexer: Assert size of `Token` in 32-bit WASM (#8292 )
(overlookmotel)
- 3149fe0 minifier: Add anonymous function test case for logical
expression to logical assignment compression (#8347 ) (sapphi-red)
- 91b42de minifier: Enable some passing tests (#8250 ) (camc314)
- 1fa5341 minifier: Port tests from ConvertToDottedPropertiesTest
(#8175 ) (sapphi-red)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com >
2025-01-11 22:34:31 +08:00
Boshen
0e14bd8cab
chore(napi/parser): publish oxc_parser_napi
...
closes #8118
2025-01-03 18:13:12 +08:00
underfin
f79e9ad91e
feat(napi/parser): add crate-type: "lib" ( #8067 )
...
The rolldown need export it to instead of `rollup/parseAst`, ref
https://rollupjs.org/javascript-api/#accessing-the-parser
2024-12-23 14:47:19 +08:00
overlookmotel
3858221f45
refactor(global): sort imports ( #7883 )
...
Pure refactor. Re-order imports for clarity:
1. `std`
2. External crates
3. `oxc_*` crates
4. Current crate `use crate::...`
5. Super `use super::...`
6. Local modules
This order is from "furthest away" to "closest". This makes it clearer to see what is coming from where.
`cargo +nightly fmt` (#7877 ) did a lot of the work, but unfortunately `rustfmt` does not have an option to (a) put workspace crates in a separate block from external crates and (b) move `mod` statements to after `use` statements.
2024-12-14 15:07:21 +00:00
Boshen
7fb9d47460
style(rust): cargo +nightly fmt ( #7877 )
2024-12-14 06:03:31 +00:00
renovate[bot]
358d375bbd
chore(deps): update rust crates ( #7787 )
2024-12-12 22:45:45 +08:00
Boshen
18d0ce3c06
fix(napi): rename Error to OxcError to avoid name collision ( #7780 )
2024-12-11 00:30:07 +08:00
Boshen
9157a0ed0f
feat(napi/parser): add getUtf16ByteOffset API; update README ( #7772 )
2024-12-10 14:15:39 +00:00
Boshen
f3cfa7f3dd
feat(napi/parser): add get_line_column_number API ( #7765 )
2024-12-10 12:49:11 +00:00
Boshen
4bd3d103d3
feat(napi/parser): introduce experimental MagicString ( #7529 )
...
Hold magic string instance on the Rust side for utf8 string manipulation.
2024-12-10 08:33:47 +00:00
Boshen
48b1e4ad32
refactor(napi/parser): enable serialize feature for oxc_ast only ( #7728 )
2024-12-08 15:38:57 +00:00
Boshen
85eec3c82e
feat(napi/transform,napi/parser): return structured error object ( #7724 )
...
closes #7261
2024-12-08 14:11:56 +00:00
Boshen
00fea9285b
feat(napi/parser): expose span positions of import.meta ( #7677 )
2024-12-05 11:03:52 +00:00
Boshen
1de2842f8e
feat(napi/parser): return EcmaScriptModule::hasModuleSyntax ( #7647 )
2024-12-04 13:00:47 +00:00
Boshen
771c698a81
feat(oxc): remove oxc_napi crate ( #7634 )
...
napi has a limitation, it cannot feature gate type exposure.
closes #7623
2024-12-04 10:07:32 +08:00
Boshen
bd977cf742
feat(oxc): add oxc_napi crate ( #7612 )
2024-12-03 14:02:47 +00:00
Boshen
40792b4440
feat(napi/parser): change parse API to accept mandatory filename and optional lang ( #7605 )
2024-12-03 12:09:48 +00:00
Boshen
7c62a33a06
feat(napi/parser): return esm info ( #7602 )
...
The parser now returns import / export statement information, which can be used for parser plugins.
2024-12-03 11:21:54 +00:00