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
Boshen
16adaf9afd
refactor(napi/parser): clean up code ( #7596 )
2024-12-03 04:48:51 +00:00
Boshen
943462f22c
feat(module_lexer)!: remove oxc_module_lexer ( #7595 )
...
This crate will no longer be relevant after we export esm information
directly from the parser.
Besides, `ex-module-lexer`'s output data is too limited for plugin
authors to use.
2024-12-03 04:22:51 +00:00
Boshen
d942a8d41a
chore: Rust v1.83.0 changes ( #7535 )
...
This PR does not upgrade rustc. Only changes are applied.
We cannot upgrade to the lastet Rust version yet due to wasm-bindgen
breaking some generated types.
THere's also some elided lifetimes in `**/generated/**`, which requires
modification to ast tools.
2024-11-29 11:59:45 +08:00
Song Gao
cf3415b0e4
chore(doc): replace main/master to tag/commit to make the url always accessible ( #7298 )
2024-11-16 21:00:30 +08:00
Boshen
24c585a20a
feat(napi/parser): reexport @oxc-project/types ( #7214 )
...
closes #7207
2024-11-09 17:24:07 +08:00
Boshen
d1d187417b
feat(ast)!: change comment.span to real position that contain // and /* ( #7154 )
...
closes #7150
2024-11-06 05:10:33 +00:00
Boshen
9ed9501bcd
fix(module_lexer): add missing export * from 'foo'; case ( #7103 )
...
fixes #7039
2024-11-03 16:31:19 +00:00
Boshen
fe28bae1e0
chore: remove unnecessary packageManager from package.json
2024-10-25 10:38:02 +08:00
ottomated
b075982eaa
fix(types): Change @oxc/types package name ( #6874 )
...
Closes #6862 .
Possible options:
- `oxc-types`
- `@oxc-project/types`
- `@oxc-ast/types`
- `oxc-ast-types`
2024-10-24 20:04:09 +00:00
ottomated
67a7bde4c6
feat(napi/parser)!: add typings to napi/parser ( #6796 )
...
- Added TypeScript annotation for `ParseResult.program`
- Modified the entrypoint for `oxc-parser` to allow wrapping the napi functions
- Updated `index.js` to parse the `program` string into a JSON object
- Updated tests
- Added a dependency on `@oxc/types`
2024-10-24 13:08:59 +00:00
Boshen
520096030a
refactor(oxc)!: remove passing Trivias around ( #6446 )
...
part of #6426
2024-10-11 06:09:25 +00:00
Boshen
5b5daec392
refactor(napi): use vitest ( #6307 )
2024-10-06 02:57:48 +00:00
Boshen
2f888ed871
feat(oxc): add napi transform options ( #6268 )
2024-10-03 13:36:38 +00:00
Boshen
aa0dbb6375
refactor(oxc): add napi feature, change napi parser to use oxc crate ( #6265 )
2024-10-03 04:28:38 +00:00
Boshen
6dd6f7ca26
refactor(ast): change Comment struct ( #5783 )
2024-09-15 09:22:58 +00:00
Boshen
63a830e08c
chore(dprint): format toml files ( #5599 )
...
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-08 14:26:16 +08:00
Boshen
dc741e471f
chore: do not format napi generated files
2024-09-08 13:42:15 +08:00
Boshen
d00a1f6511
chore: use dprint to format js, json and markdown
2024-09-08 13:24:58 +08:00
Boshen
f5f3d08a51
build: use pnpm catalog
2024-09-07 13:15:43 +08:00
Boshen
1bed5ce2a5
chore: run cargo +nightly fmt to sort imports ( #5503 )
...
They are never going to be stable are they ... cedf7a4daa/.rustfmt.toml (L8-L16)
2024-09-06 04:04:26 +00:00
Boshen
a03b24d94e
ci: add napi tests ( #5419 )
2024-09-03 12:24:58 +08:00
Kevin Deng 三咲智子
bf49f339d0
chore: pin pnpm version & upgrade lockfile version ( #5200 )
2024-08-25 22:57:33 +08:00
Boshen
b2ff2df5af
refactor(parser)!: remove builder pattern from Parser struct ( #5000 )
...
part of #4455
use `with_options(ParseOptions { ..ParseOptions::default() })` API instead.
2024-08-20 07:40:25 +00:00
Boshen
27cbd551fb
chore: bump napi to v3 ( #4365 )
2024-07-19 14:06:33 +00:00
Luca Bruno
5731e3957f
refactor(ast)!: store span details inside comment struct ( #4132 )
...
This tweaks `Comment` definition in order to internally store the start
and end position of its span.
Closes: https://github.com/oxc-project/oxc/issues/4069
2024-07-09 23:23:43 +08:00
Boshen
720983a965
feat(napi/transform): allow setting sourceType to transform ( #4113 )
...
closes #4071
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-07-08 19:09:45 +08:00
burlinchen
38e7351a91
chore(napi): Refactor async parsing functions to remove tokio dependency ( #4049 )
...
Resolves #4044
- Added `use napi::{bindgen_prelude::AsyncTask, Task}` to handle async
tasks without tokio.
- Introduced `ResolveTask` struct implementing `Task` for asynchronous
parsing.
- Replaced `parse_sync` function implementation with `parse_with_return`
to reuse code.
- Refactored `parse_async` to use `AsyncTask` and `ResolveTask` for
async parsing.
- Removed tokio dependency by avoiding `tokio::spawn` and using
`AsyncTask` for async operations.
This refactor enhances code readability and removes the dependency on
tokio, streamlining the async task handling within the napi framework.
2024-07-04 20:31:19 +08:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt
2024-06-19 00:48:30 +08:00
Boshen
0b8098a442
feat(napi): isolated-declaration ( #3718 )
2024-06-17 13:06:00 +00:00
Rihards Gravis
dbf7c3aaa2
fix(napi/parser): typescript types for Comment is out of order ( #3646 )
...
Fix `oxc-parser` Typescript type definition for `Comment` type where the
`type` and `value` have reversed types in place.
2024-06-13 00:20:26 +08:00
Boshen
dbde5b3a04
refactor(diagnostics): remove export of miette
2024-05-12 11:46:48 +08:00
Boshen
2064ae9e0a
refactor(parser,diagnostic): one diagnostic struct to eliminate monomorphization of generic types ( #3214 )
...
part of #3213
We should only have one diagnostic struct instead 353 copies of them, so we don't end up choking LLVM with 50k lines of the same code due to monomorphization.
If the proposed approach is good, then I'll start writing a codemod to turn all the existing structs to plain functions.
---
Background:
Using `--timings`, we see `oxc_linter` is slow on codegen (the purple part).

The crate currently contains 353 miette errors. [cargo-llvm-lines](https://github.com/dtolnay/cargo-llvm-lines ) displays
```
cargo llvm-lines -p oxc_linter --lib --release
Lines Copies Function name
----- ------ -------------
830350 33438 (TOTAL)
29252 (3.5%, 3.5%) 808 (2.4%, 2.4%) <alloc::boxed::Box<T,A> as core::ops::drop::Drop>::drop
23298 (2.8%, 6.3%) 353 (1.1%, 3.5%) miette::eyreish::error::object_downcast
19062 (2.3%, 8.6%) 706 (2.1%, 5.6%) core::error::Error::type_id
12610 (1.5%, 10.1%) 65 (0.2%, 5.8%) alloc::raw_vec::RawVec<T,A>::grow_amortized
12002 (1.4%, 11.6%) 706 (2.1%, 7.9%) miette::eyreish::ptr::Own<T>::boxed
9215 (1.1%, 12.7%) 115 (0.3%, 8.2%) core::iter::traits::iterator::Iterator::try_fold
9150 (1.1%, 13.8%) 1 (0.0%, 8.2%) oxc_linter::rules::RuleEnum::read_json
8825 (1.1%, 14.9%) 353 (1.1%, 9.3%) <miette::eyreish::error::ErrorImpl<E> as core::error::Error>::source
8822 (1.1%, 15.9%) 353 (1.1%, 10.3%) miette::eyreish::error::<impl miette::eyreish::Report>::construct
8119 (1.0%, 16.9%) 353 (1.1%, 11.4%) miette::eyreish::error::object_ref
8119 (1.0%, 17.9%) 353 (1.1%, 12.5%) miette::eyreish::error::object_ref_stderr
7413 (0.9%, 18.8%) 353 (1.1%, 13.5%) <miette::eyreish::error::ErrorImpl<E> as core::fmt::Display>::fmt
7413 (0.9%, 19.7%) 353 (1.1%, 14.6%) miette::eyreish::ptr::Own<T>::new
6669 (0.8%, 20.5%) 39 (0.1%, 14.7%) alloc::raw_vec::RawVec<T,A>::try_allocate_in
6173 (0.7%, 21.2%) 353 (1.1%, 15.7%) miette::eyreish::error::<impl miette::eyreish::Report>::from_std
6027 (0.7%, 21.9%) 70 (0.2%, 16.0%) <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
6001 (0.7%, 22.7%) 353 (1.1%, 17.0%) miette::eyreish::error::object_drop
6001 (0.7%, 23.4%) 353 (1.1%, 18.1%) miette::eyreish::error::object_drop_front
5648 (0.7%, 24.1%) 353 (1.1%, 19.1%) <miette::eyreish::error::ErrorImpl<E> as core::fmt::Debug>::fmt
```
It's totalling more than 50k llvm lines, and is putting pressure on rustc codegen (the purple part on `oxc_linter` in the image above.
---
It's pretty obvious by looking at https://github.com/zkat/miette/blob/main/src/eyreish/error.rs , the generics can expand out to lots of code.
2024-05-11 04:56:22 +00:00