Commit graph

426 commits

Author SHA1 Message Date
Dunqing
8ed976661a
fix(codegen): source map builder panicked because it attempted to subtract with overflow in search_original_line_and_column (#8185)
See:
https://github.com/oxc-project/monitor-oxc/actions/runs/12531534720/job/34949348092
Related: #7926 

This line causes panic.

46fc1a8b7d/crates/oxc_codegen/src/sourcemap_builder.rs (L147-L148)

After investigation, I found that the root cause was the code removed
in this PR. I don’t understand what the code was used for, but it was
obviously wrong. Because `idx` is always smaller than `cap`
2024-12-31 20:00:41 +08:00
Boshen
ad146bbb90 feat(codegen): print real newline when \n is inside template literals (#8178) 2024-12-29 12:20:47 +00:00
Boshen
ad61e70186 fix(codegen): print if else without block with proper indentation (#8135) 2024-12-27 00:39:52 +00:00
oxc-bot
5a1311e76c
release(crates): v0.44.0 (#8110)
## [0.44.0] - 2024-12-25

- ad2a620 ast: [**BREAKING**] Add missing
`AssignmentTargetProperty::computed` (#8097) (Boshen)

### Features

- c2daa20 ast: Add `Expression::into_inner_expression` (#8048)
(overlookmotel)
- 618b6aa codege: Minify whitespace in object getter / setter (#8080)
(Boshen)
- 4727667 codegen: Minify arrow expr `(x) => y` -> `x => y` (#8078)
(Boshen)
- 0562830 codegen: Minify string with backtick when needed (#8095)
(Boshen)
- 6237c05 codegen: Minify more whitespace (#8089) (Boshen)
- 6355b7c codegen: Minify `export { 's' as 's' }` -> `export { 's' }`
(#8093) (Boshen)
- fccfda9 codegen: Minify `class{static[computed]}` (#8088) (Boshen)
- f873139 codegen: Minify `for (_ of [])` -> `for(_ of[])` (#8086)
(Boshen)
- 8b8cbcd codegen: Minify `case "foo"` -> `case"foo"` (#8085) (Boshen)
- 414c118 codegen: Minify `yield "s"` -> `yield"s"` (#8084) (Boshen)
- f8f067b codegen: Minify class method `async*fn(){}` (#8083) (Boshen)
- 1d5ae81 codegen: Minify `const [foo] = bar` -> `const[foo]=bar`
(#8079) (Boshen)
- e3f78fb codegen: `new Foo()` -> `new Foo` when minify (#8077) (Boshen)
- d84d60a codegen: Minify numbers with large exponents (#8074) (Boshen)
- 373279b codegen: Balance string quotes when minify whitespace (#8072)
(Boshen)
- 5397fe9 minifier: Constant fold `undefined?.bar` -> `undefined`
(#8075) (Boshen)
- 1932f1e minifier: Fold `foo === undefined || foo === null` (#8063) (翠
/ green)
- 11c4bd8 span: Implement source type `{file basename}.d.{extension}.ts`
(#8109) (Boshen)
- be4feb4 syntax: Add `SymbolId::new` method (#8041) (overlookmotel)
- e632a7b transformer: Remove typescript symbols after transform (#8069)
(Boshen)

### Bug Fixes

- bdc241d codegen: Disallow template literals in object property key
(#8108) (Boshen)
- 728ed20 codegen: Print `yield * ident` correctly (Boshen)
- b605baa minifier: Constant fold strings with tab char (#8096) (Boshen)
- de82492 parser: Report syntax errors for missing constructor
implementations (#8081) (camc314)
- 55d6eb9 parser: Disallow type parameters on class constructors (#8071)
(injuly)
- be2c60d parser: Parse `import source from from 'mod'` (#8056) (Boshen)
- 708e9cf semantic: Report errors for missing class method impls (#8082)
(camc314)
- 3057686 transformer/class-properties: Unwrap parenthesised expressions
(#8049) (overlookmotel)
- e67cd05 transformer/class-properties: Correctly resolve private fields
pointing to private accessors (#8047) (overlookmotel)
- 6b08c6e transformer/class-properties: Correctly resolve private fields
pointing to private methods (#8042) (overlookmotel)
- 274f117 transformer/nullish-coalescing: Use correct scope id for
binding (#8053) (camc314)

### Performance

- 78d2e83 sourcemap: Improve perf of `search_original_line_and_column`
(#7926) (Cameron)

### Refactor

- 7110c7b codegen: Add `print_quoted_utf16` and `print_unquoted_utf16`
methods (#8107) (Boshen)
- 8b54d89 minifier: Remove parens must happen on enter (#8060) (Boshen)
- 7cb84f3 minifier: Only minify on ast node exit (#8059) (Boshen)
- 77d845a minifier: Fuse DCE AST passes (#8058) (Boshen)
- 6123f5e minifier: Fold statements on exit (#8057) (Boshen)
- cbd5169 transformer/class-properties: Do not recreate private field if
not transforming it (#8044) (overlookmotel)
- 98e8a72 transformer/class-properties: Do not take mut ref when immut
ref will do (#8040) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-25 21:03:09 +08:00
Boshen
bdc241d41d fix(codegen): disallow template literals in object property key (#8108) 2024-12-25 11:22:54 +00:00
Boshen
7110c7b94c refactor(codegen): add print_quoted_utf16 and print_unquoted_utf16 methods (#8107) 2024-12-25 09:19:55 +00:00
Boshen
47276679f5 feat(codegen): minify arrow expr (x) => y -> x => y (#8078) 2024-12-24 14:25:01 +00:00
Boshen
728ed20c1c
fix(codegen): print yield * ident correctly 2024-12-24 21:57:58 +08:00
Boshen
0562830549 feat(codegen): minify string with backtick when needed (#8095) 2024-12-24 13:39:31 +00:00
Boshen
ad2a620d61 fix(ast)!: add missing AssignmentTargetProperty::computed (#8097) 2024-12-24 13:27:00 +00:00
Boshen
6237c0527f feat(codegen): minify more whitespace (#8089) 2024-12-24 09:54:13 +00:00
Boshen
6355b7ca70 feat(codegen): minify export { 's' as 's' } -> export { 's' } (#8093) 2024-12-24 09:17:51 +00:00
Boshen
fccfda91c1 feat(codegen): minify class{static[computed]} (#8088) 2024-12-24 05:06:57 +00:00
Boshen
f873139a0f feat(codegen): minify for (_ of []) -> for(_ of[]) (#8086) 2024-12-24 04:17:50 +00:00
Boshen
8b8cbcd2db feat(codegen): minify case "foo" -> case"foo" (#8085) 2024-12-24 01:07:58 +00:00
Boshen
414c118309 feat(codegen): minify yield "s" -> yield"s" (#8084) 2024-12-24 00:41:28 +00:00
Boshen
f8f067bfc6 feat(codegen): minify class method async*fn(){} (#8083) 2024-12-24 00:35:29 +00:00
Boshen
618b6aa085 feat(codege): minify whitespace in object getter / setter (#8080) 2024-12-23 16:36:03 +00:00
Boshen
1d5ae817d7 feat(codegen): minify const [foo] = bar -> const[foo]=bar (#8079) 2024-12-23 16:20:37 +00:00
Boshen
e3f78fba0b feat(codegen): new Foo() -> new Foo when minify (#8077) 2024-12-23 15:34:31 +00:00
Boshen
d84d60a3a9 feat(codegen): minify numbers with large exponents (#8074) 2024-12-23 13:35:52 +00:00
Boshen
373279b7f4 feat(codegen): balance string quotes when minify whitespace (#8072) 2024-12-23 13:24:22 +00:00
Cameron
78d2e837f0
perf(sourcemap): improve perf of search_original_line_and_column (#7926)
this seems to show a decent speed up on perf.
the thinking behind this change is:
1. subsequent calls to `search_original_line_and_column` will **never**
look at back at lines it has already searched
2. binary search is faster in this case as typically `idx` is only
increased by a small amount

Given this, we can skip checking a bunch of lines (that will never
return true) improving performance.

This is a very hot path. 


```
$ hyperfine --warmup=3 ./target/release-with-debug/examples/sourcemap-main ./target/release-with-debug/examples/sourcemap
Benchmark 1: ./target/release-with-debug/examples/sourcemap-main
  Time (mean ± σ):      79.5 ms ±   5.5 ms    [User: 65.1 ms, System: 12.2 ms]
  Range (min … max):    76.8 ms … 111.7 ms    37 runs
 
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
 
Benchmark 2: ./target/release-with-debug/examples/sourcemap
  Time (mean ± σ):      72.9 ms ±   0.9 ms    [User: 59.2 ms, System: 12.2 ms]
  Range (min … max):    70.6 ms …  75.0 ms    40 runs
 
Summary
  ./target/release-with-debug/examples/sourcemap ran
    1.09 ± 0.08 times faster than ./target/release-with-debug/examples/sourcemap-main
```

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2024-12-23 14:51:50 +08:00
oxc-bot
d69de3629d
release(crates): v0.43.0 (#8054)
## [0.43.0] - 2024-12-21

- de4c772 traverse: [**BREAKING**] Rename `Ancestor::is_via_*` methods
to `is_parent_of_*` (#8031) (overlookmotel)

- ed75e42 semantic: [**BREAKING**] Make SymbolTable fields `pub(crate)`
instead of `pub` (#7999) (Boshen)

### Features

- 75b775c allocator: `Vec<u8>::into_string` (#8017) (overlookmotel)
- 8547e02 ast: Implement `allocator_api2` for `Allocator` (#8043)
(Boshen)
- 63a95e4 ast: Add `AstBulder::move_property_key` (#7998)
(overlookmotel)
- 897a1a8 transformer/class-properties: Exit faster from super
replacement visitor (#8028) (overlookmotel)
- 3ea4109 transformer/class-properties: Transform super update
expressions within static prop initializer (#7997) (Dunqing)
- cc57db3 transformer/class-properties: Transform super assignment
expressions within static prop initializer (#7991) (Dunqing)
- 6b6444b traverse: Record current block scope (#8007) (overlookmotel)

### Bug Fixes

- 043252d transformer/class-properties: Replace `this` and class name in
static blocks (#8035) (overlookmotel)
- 273795d transformer/class-properties: Run other transforms on static
properties, static blocks, and computed keys (#7982) (overlookmotel)

### Performance

- c0dd3f8 ast: `move_expression` and `move_statement` produce dummy with
no span (#7995) (overlookmotel)
- 862838f codegen: Remove useless to_owned (#8014) (Dunqing)
- 2736657 semantic: Allocate `UnresolvedReferences` in allocator (#8046)
(Boshen)
- 2e8872c semantic: Allocate child scope in allocator (#8045) (Boshen)
- 414e828 semantic: Allocate symbol data in Allocator (#8012) (Boshen)
- 7aebed0 semantic: Allocate `Bindings` in allocator (#8021) (Boshen)
- 0f9308f transformer/react-refresh: Reduce allocations (#8018)
(overlookmotel)
- 0deb9e6 transformer/react-refresh: Reserve capacity in hook key string
(#8016) (overlookmotel)
- 7b70347 transformer/react-refresh: Avoid allocating string in each
hook call (#8013) (Dunqing)

### Documentation

- df5c341 ast: Improve docs for `AstBuilder::move_*` methods (#7994)
(overlookmotel)

### Refactor

- f1adf9f semantic: `ScopeTree::rename_binding` remove old binding first
(#8020) (overlookmotel)
- 02f968d semantic: Change `Bindings` to a plain `FxHashMap` (#8019)
(Boshen)
- e7476a1 semantic: Remove `serialize` (#8015) (Boshen)
- 1cf7b83 semantic: Simplify handling namespace stack (#7987) (Dunqing)
- 48cb52b semantic: Remove resetting `current_reference_flags` in visit
functions (#7986) (Dunqing)
- 3250a47 semantic: Remove unused current_symbol_flags (#7985) (Dunqing)
- efe96ec semantic: Use `Stack` for function stack node ids (#7984)
(Dunqing)
- ac097e9 transformer/class-properties: Rename file (#8036)
(overlookmotel)
- 059a5dd transformer/class-properties: Do not pass `ScopeId` into
`insert_instance_inits` (#8001) (overlookmotel)
- 0a38eea transformer/class-properties: Use `temp_var_name_base` to
generate temp var names for `super` transform (#8004) (overlookmotel)
- d1b7181 transformer/class-properties: Rename var (#8006)
(overlookmotel)
- 5a23d72 transformer/class-properties: Remove outdated comment (#8000)
(overlookmotel)
- b3a5f3e transformer/class-properties: Mark
`transform_assignment_expression_if_super_member_assignment_target` as
inline (#7993) (Dunqing)

### Testing

- bcb33c0 semantic: Add a test for catch parameters reference (#7988)
(Dunqing)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-21 15:07:21 +08:00
Dunqing
862838fd28 perf(codegen): remove useless to_owned (#8014) 2024-12-19 12:06:55 +00:00
oxc-bot
3631eed975
release(crates): v0.42.0 (#7983)
## [0.42.0] - 2024-12-18

- 84b75a0 semantic: [**BREAKING**] Remove `ScopeFlags::Modifiers`
(#7935) (overlookmotel)

- c071494 semantic: [**BREAKING**] Remove `SymbolTable::rename` method
(#7868) (overlookmotel)

### Features

- 8b7c5ae ast: Add `AstBuilder::atom_from_cow` (#7974) (overlookmotel)
- 46e2e27 data_structures: Implement `Default` for `NonEmptyStack`
(#7946) (overlookmotel)
- db9e93b mangler: Mangle top level variables (#7907) (翠 / green)
- 075bd16 minifier: Fold bitwise operation (#7908) (翠 / green)
- c16a851 napi/transform: Add `jsx: 'preserve'` option (#7965) (Boshen)
- 81eedb1 parser: 'readonly' type modifier is only permitted on array
and tuple literal types. (#7880) (Boshen)
- b9322c6 semantic: Re-export all flags and ID types (#7886)
(overlookmotel)
- c30a982 span: Add `impl From<ArenaString> for Atom` (#7973)
(overlookmotel)
- 02b653c transformer/class-properties: Do not create temp var for
template literal computed key (#7919) (overlookmotel)
- feac02e transformer/class-properties: Only rename symbols if necessary
(#7896) (overlookmotel)
- 6bc530d transformer/class-properties: Transform super call expression
that is inside static prop initializer (#7831) (Dunqing)
- 53e2bc0 traverse: Add `TraverseScoping::rename_symbol` method (#7871)
(overlookmotel)

### Bug Fixes

- 3659e6d cfg: Include export default code in CFG instructions (#7862)
(Jan Olaf Martin)
- 850dd43 codegen: Missing `,` when generating type parameters with jsx
(#7929) (Dunqing)
- 4799471 minfier: Bigint bitwise operation only works with bigint
(#7937) (Boshen)
- de8a86e minifier: Incorrect minification in `try_fold_left_child_op`
(#7949) (翠 / green)
- 9a30910 oxc_transformer: Inject_global_variables should considering
string imported name (#7768) (IWANABETHATGUY)
- 111dc52 parser: Include export token in spans of
TSNamespaceExportDeclaration (#7963) (branchseer)
- 14c51ff semantic: Remove inherting `ScopeFlags::Modifier` from parent
scope (#7932) (Dunqing)
- 596aead semantic: Reset references flags when resolved (#7923)
(Dunqing)
- 4924073 semantic: `ScopeTree::rename_binding` preserve order of
bindings (#7870) (overlookmotel)
- bb38065 transformer/class-properties: Do not transform `super.prop` in
nested method within static prop initializer (#7978) (overlookmotel)
- e76fbb0 transformer/class-properties: Fix symbol clashes in instance
prop initializers (#7872) (overlookmotel)
- c0576fa transformer/class-properties: Use UID for `args` in created
class constructor (#7866) (overlookmotel)
- d660d8d transformer/optional-chaining: Do not create unused reference
when `noDocumentAll` assumption (#7847) (overlookmotel)
- 4920c6a transformer/optional-chaining: Avoid creating a useless
reference when `noDocumentAll` is true (#7832) (Dunqing)

### Performance

- a5f04a7 ast: Faster `Comment::is_jsdoc` (#7905) (overlookmotel)
- 4b24335 codegen: Improve printing of statement comments (#7857)
(Boshen)
- 71a40a2 codegen: Guard comment printing comments when there are no
comments (#7856) (Boshen)
- b31f123 transformer/class-properties: Do not re-generate same method
key (#7915) (overlookmotel)
- 8ca8fce transformer/class-properties: Reduce work updating scopes when
transforming static prop initializers (#7904) (overlookmotel)
- 80d0b3e transformer/class-properties: Fast path for instance prop
initializer scope re-parenting (#7901) (overlookmotel)
- 38aafa2 transformer/class-properties: Reduce size of
`transform_call_expression_for_super_member_expr` (#7859)
(overlookmotel)

### Documentation

- e49de81 ast: Document `Expression::is_*` methods (#7853)
(overlookmotel)
- 10a86b9 transformer: Fix comments (#7925) (overlookmotel)
- f4cb5d3 transformer: Clarify comment (#7918) (overlookmotel)
- 41a1456 transformer/class-properties: Correct doc comments (#7966)
(overlookmotel)
- 18441af transformer/class-properties: Remove oudated todo for
assignment expression (#7955) (Dunqing)
- 1317c00 transformer/class-properties: Clarify doc comments (#7914)
(overlookmotel)
- 9989b58 transformer/class-properties: Re-order file list in doc
comment (#7911) (overlookmotel)
- 7390048 transformer/class-properties: Reformat doc comment (#7909)
(overlookmotel)

### Refactor

- beb982a ast: Use exhaustive match for `Argument` to
`ArrayExpressionElement` conversion (#7848) (overlookmotel)
- 3858221 global: Sort imports (#7883) (overlookmotel)
- 1314c97 minifier: Expose dce as an API instead of an option (#7957)
(Boshen)
- 6551dfe semantic: Pass `&str` instead of `Cow` (#7972) (overlookmotel)
- b8d2bd2 semantic: Move determining references flags for export
specifier to `visit_export_named_declaration` (#7924) (Dunqing)
- 98d7946 semantic: Import flags and ID types from `oxc_syntax` (#7887)
(overlookmotel)
- 1cf8f8f semantic: `SymbolTable::set_name` return old name (#7869)
(overlookmotel)
- 5d42df8 semantic: Use `Expression::is_super` (#7851) (overlookmotel)
- 8cf9766 semantic, syntax, wasm: Remove `#![allow(non_snake_case)]`
(#7863) (overlookmotel)
- d59bbae transformer: Remove unneeded lint `#[allow]` (#7971)
(overlookmotel)
- 2c94236 transformer: Improve encapsulation of transforms (#7888)
(overlookmotel)
- 34091b2 transformer: Use `Expression::is_super` (#7852)
(overlookmotel)
- d4d7bc0 transformer/async-to-generator: Avoid allocating unnecessary
`Atom`s (#7975) (overlookmotel)
- 2e5ffd3 transformer/class-properties: Store `temp_var_is_created` on
`ClassBindings` (#7981) (overlookmotel)
- 27cc6da transformer/class-properties: Store `is_declaration` only on
`ClassDetails` (#7980) (overlookmotel)
- ee282f8 transformer/class-properties: Remove `move_expression`s
(#7979) (overlookmotel)
- 94b376a transformer/class-properties: Simplify logic for when to
create temp binding (#7977) (overlookmotel)
- ff9d1b3 transformer/class-properties: Comments about shorter output
(#7976) (overlookmotel)
- 6fc40f0 transformer/class-properties: Pass `BoundIdentifier`s by
reference (#7968) (overlookmotel)
- 69eeeea transformer/class-properties: Methods take `&self` where
possible (#7967) (overlookmotel)
- 98340bb transformer/class-properties: Use stack of `ClassDetails`
(#7947) (overlookmotel)
- 088dd48 transformer/class-properties: Shorten code (#7913)
(overlookmotel)
- 544ffbf transformer/class-properties: Split up code into multiple
files (#7912) (overlookmotel)
- dcaf674 transformer/class-properties: Rename file (#7910)
(overlookmotel)
- 6243980 transformer/class-properties: Instance prop inits visitor use
`Visit` (#7867) (overlookmotel)
- eb47d43 transformer/class-properties: Re-use existing `Vec` (#7854)
(overlookmotel)
- 1380b7b transformer/class-properties: Reduce visibility of method
(#7858) (overlookmotel)
- 0f5e078 transformer/class-properties: Rename `*_owner` to `owned_*`
(#7855) (Dunqing)
- 4ea90d4 transformer/react-refresh: Calculate signature key once
(#7970) (Dunqing)
- 15b9bff transformer/typescript: Reuse `Atom` (#7969) (overlookmotel)

### Styling

- fb897f6 data_structures: Add line break (#7882) (overlookmotel)
- 7fb9d47 rust: `cargo +nightly fmt` (#7877) (Boshen)

### Testing

- 523d48c transformer: Move named test to exports folder (#7922)
(Dunqing)
- e766051 transformer: Skip test which uses filesystem under miri
(#7874) (overlookmotel)
- f39e65e transformer: Prevent lint error when running miri (#7873)
(overlookmotel)

Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
2024-12-18 11:48:12 +08:00
Dunqing
850dd43597 fix(codegen): missing , when generating type parameters with jsx (#7929)
close: #7917
2024-12-16 05:35:06 +00: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
Boshen
4b2433539b perf(codegen): improve printing of statement comments (#7857)
closes #7814
2024-12-13 15:20:28 +00:00
Boshen
71a40a222f perf(codegen): guard comment printing comments when there are no comments (#7856) 2024-12-13 15:12:09 +00:00
oxc-bot
1428527da6
release(crates): v0.41.0 (#7846)
## [0.41.0] - 2024-12-13

- fb325dc ast: [**BREAKING**] `span` field must be the first element
(#7821) (Boshen)

- 96a26d3 ast: [**BREAKING**] Rename `is_strict` methods to
`has_use_strict_directive` (#7783) (overlookmotel)

### Features

- 8991f33 ast: Add `visit_span` to `Visit` and `VisitMut` (#7816)
(overlookmotel)
- f7900ab ast: Add `ArrowFunctionExpression::has_use_strict_directive`
method (#7784) (overlookmotel)
- e727ae9 transformer/class-properties: Transform super member
expressions that are inside static prop initializer (#7815) (Dunqing)

### Bug Fixes

- 7610dc1 parser: Parse `import source from 'mod'` (#7833) (Boshen)
- 9479e2b semantic: Missing references when `export {}` references a
type-only binding and a normal (#7812) (Yunfei He)
- 7a83230 semantic: Missing reference when `export default` references a
type alias binding (#7813) (Dunqing)
- 4a3bca8 semantic: Fix identifying strict mode arrow functions (#7785)
(overlookmotel)
- 5b7e1ad transformer: Remove span of define value (#7811) (Hiroshi
Ogawa)
- 14896cb transformer/class-properties: Create temp vars in correct
scope (#7824) (overlookmotel)
- 25bb6da transformer/class-properties: Fix `ScopeId`s in instance prop
initializers (#7823) (overlookmotel)
- 65b109a transformer/class-properties: No `raw` for generated
`StringLiteral` (#7825) (overlookmotel)
- 2964a61 transformer/class-properties: Unwrap failed when private field
expression doesn't contain optional expression in `ChainExpression`
(#7798) (Dunqing)
- 6fa6785 transformer/class-properties: Panic when the callee or member
is `ParenthesisExpression` or TS-syntax expressions. (#7795) (Dunqing)
- bb22c67 transformer/class-properties: Fix `ScopeId`s in static prop
initializers (#7791) (overlookmotel)
- caa57f1 transformer/class-properties: Fix scope flags in static prop
initializers (#7786) (overlookmotel)

### Performance

- 4448b63 codegen: Faster writing indentation (#7820) (overlookmotel)
- afaaffa codegen: Fast path for `options.print_comments()` (#7806)
(Boshen)

### Refactor

- 0f367e5 semantic: Improve the logic of resolving references to be
cleaner (#7829) (Dunqing)
- 5710950 semantic: Move export-related reference flags logic to visit
functions (#7828) (Dunqing)
- b290ebd transformer: Handle `<CWD>` in test runner (#7799) (Dunqing)
- e70deb9 transformer/class-properties: Locate instance props insertion
location in separate step (#7819) (overlookmotel)
- afc5f1e transformer/class-properties: De-deduplicate code (#7805)
(overlookmotel)
- 47a91d2 transformer/class-properties: Shorten code (#7804)
(overlookmotel)
- 54ef2b9 transformer/class-properties: Rename
`debug_assert_expr_is_not_parenthesis_or_typescript_syntax` (#7803)
(overlookmotel)
- 3cdc47c transformer/class-properties: `#[inline(always)]` on
`assert_expr_neither_parenthesis_nor_typescript_syntax` (#7802)
(overlookmotel)

### Testing

- d72c888 transformer/replace-global-defines: Remove panicking test
(#7838) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-13 21:25:13 +08:00
overlookmotel
4448b63692 perf(codegen): faster writing indentation (#7820)
Write indentation faster. Previously was writing indentation to buffer with a call to `memset`, which is relatively expensive. Where indentation `<= 16` (common case), write 16 tabs with a single 16-byte XMM write, which is faster.
2024-12-13 05:17:32 +00:00
Boshen
afaaffa262 perf(codegen): fast path for options.print_comments() (#7806) 2024-12-11 15:13:30 +00:00
oxc-bot
bd572c609b
release(crates): v0.40.1 (#7781)
## [0.40.1] - 2024-12-10

### Bug Fixes

- 18d0ce3 napi: Rename `Error` to `OxcError` to avoid name collision
(#7780) (Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-11 00:35:34 +08:00
oxc-bot
6768f7ded2
release(crates): v0.40.0 (#7775) 2024-12-10 23:04:43 +08:00
Boshen
a222f2b055 fix(codegen): print delete 2e308 as delete (0, Infinity) (#7761)
closes #7736
2024-12-10 08:37:50 +00:00
Boshen
b701232098 fix(codegen): print quote correctly for directive (#7735)
closes #7734
2024-12-09 07:17:02 +00:00
Boshen
72eab6cd96 feat(parser)!: stage 3 import source and import defer (#7706)
* https://github.com/tc39/proposal-defer-import-eval
* https://github.com/tc39/proposal-source-phase-imports
* https://tc39.es/proposal-source-phase-imports/#sec-ecmascript-language-expressions
* https://tc39.es/proposal-defer-import-eval/#prod-NameSpaceImport
2024-12-06 16:15:52 +00:00
Dunqing
8c3a954336 fix(codegen): missing parens for in in for in loop init (#7705)
Well, this looks like an accidental change before, `Context::empty().and_forbid_in(false)` does nothing at all.
2024-12-06 15:52:05 +00:00
Dunqing
4afbe5599e fix(codegen): missing parens for in in for loop init when it includes two binary expression (#7703)
close: #7690

I don't know the logic much, it works without `left_ctx` and no tests failed
2024-12-06 15:52:04 +00:00
Boshen
d0b78f7361 feat(codegen): minify whitespace for some expressions (#7671)
part of #7638
2024-12-05 06:59:17 +00:00
Song Gao
ebc80f6749
refactor(ast)!: change 'raw' from &str to Option<Atom> (#7547)
Fix #7254 

Changed all "raw" properties of literal types (if they have this property) to `Option<Atom>`.

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2024-12-05 00:34:45 +00:00
Boshen
c523ccb7ef feat(codegen): better whitespace minification for import / export statements (#7650)
part of #7638
2024-12-04 19:24:03 +00:00
oxc-bot
fee2143f4c
release(crates): v0.39.0 (#7643) 2024-12-04 19:43:22 +08:00
Boshen
e787e9d41a fix(codegen): print parentheses correctly for ClassHeritage (#7637)
closes #7631
2024-12-04 06:43:32 +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
oxc-bot
00a7372eaf
release(crates): v0.38.0 (#7490) 2024-11-26 14:38:47 +08:00
Hiroshi Ogawa
d5df615264
fix(oxc_codegen): don't emit empty span mapping (#7448) 2024-11-24 17:04:52 +08:00
oxc-bot
0918e520cf
release(crates): v0.37.0 (#7399) 2024-11-21 22:27:55 +08:00