diff --git a/Cargo.lock b/Cargo.lock index 58072619db410..7ea9e73b586b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1273,7 +1273,7 @@ checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" [[package]] name = "oxc" -version = "0.22.1" +version = "0.23.0" dependencies = [ "oxc_allocator", "oxc_ast", @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "oxc_allocator" -version = "0.22.1" +version = "0.23.0" dependencies = [ "allocator-api2", "bumpalo", @@ -1320,7 +1320,7 @@ dependencies = [ [[package]] name = "oxc_ast" -version = "0.22.1" +version = "0.23.0" dependencies = [ "bitflags 2.6.0", "num-bigint", @@ -1354,7 +1354,7 @@ dependencies = [ [[package]] name = "oxc_ast_macros" -version = "0.22.1" +version = "0.23.0" [[package]] name = "oxc_benchmark" @@ -1379,7 +1379,7 @@ dependencies = [ [[package]] name = "oxc_cfg" -version = "0.22.1" +version = "0.23.0" dependencies = [ "bitflags 2.6.0", "itertools 0.13.0", @@ -1390,7 +1390,7 @@ dependencies = [ [[package]] name = "oxc_codegen" -version = "0.22.1" +version = "0.23.0" dependencies = [ "base64", "bitflags 2.6.0", @@ -1445,7 +1445,7 @@ dependencies = [ [[package]] name = "oxc_diagnostics" -version = "0.22.1" +version = "0.23.0" dependencies = [ "miette", "owo-colors", @@ -1455,14 +1455,14 @@ dependencies = [ [[package]] name = "oxc_index" -version = "0.22.1" +version = "0.23.0" dependencies = [ "serde", ] [[package]] name = "oxc_isolated_declarations" -version = "0.22.1" +version = "0.23.0" dependencies = [ "insta", "oxc_allocator", @@ -1559,7 +1559,7 @@ dependencies = [ [[package]] name = "oxc_mangler" -version = "0.22.1" +version = "0.23.0" dependencies = [ "itertools 0.13.0", "oxc_ast", @@ -1570,7 +1570,7 @@ dependencies = [ [[package]] name = "oxc_minifier" -version = "0.22.1" +version = "0.23.0" dependencies = [ "insta", "num-bigint", @@ -1604,7 +1604,7 @@ dependencies = [ [[package]] name = "oxc_module_lexer" -version = "0.22.1" +version = "0.23.0" dependencies = [ "oxc_allocator", "oxc_ast", @@ -1614,7 +1614,7 @@ dependencies = [ [[package]] name = "oxc_parser" -version = "0.22.1" +version = "0.23.0" dependencies = [ "assert-unchecked", "bitflags 2.6.0", @@ -1707,7 +1707,7 @@ dependencies = [ [[package]] name = "oxc_semantic" -version = "0.22.1" +version = "0.23.0" dependencies = [ "assert-unchecked", "indexmap", @@ -1731,7 +1731,7 @@ dependencies = [ [[package]] name = "oxc_sourcemap" -version = "0.22.1" +version = "0.23.0" dependencies = [ "base64-simd", "cfg-if", @@ -1743,7 +1743,7 @@ dependencies = [ [[package]] name = "oxc_span" -version = "0.22.1" +version = "0.23.0" dependencies = [ "compact_str", "miette", @@ -1755,7 +1755,7 @@ dependencies = [ [[package]] name = "oxc_syntax" -version = "0.22.1" +version = "0.23.0" dependencies = [ "bitflags 2.6.0", "dashmap 6.0.1", @@ -1800,7 +1800,7 @@ dependencies = [ [[package]] name = "oxc_transform_napi" -version = "0.22.1" +version = "0.23.0" dependencies = [ "napi", "napi-build", @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "oxc_transformer" -version = "0.22.1" +version = "0.23.0" dependencies = [ "dashmap 6.0.1", "indexmap", @@ -1838,7 +1838,7 @@ dependencies = [ [[package]] name = "oxc_traverse" -version = "0.22.1" +version = "0.23.0" dependencies = [ "compact_str", "memoffset", diff --git a/Cargo.toml b/Cargo.toml index d0e55b323d75c..c5154d639b268 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,26 +75,26 @@ doc_lazy_continuation = "allow" # FIXME [workspace.dependencies] # publish = true -oxc = { version = "0.22.1", path = "crates/oxc" } -oxc_allocator = { version = "0.22.1", path = "crates/oxc_allocator" } -oxc_ast = { version = "0.22.1", path = "crates/oxc_ast" } -oxc_codegen = { version = "0.22.1", path = "crates/oxc_codegen" } -oxc_diagnostics = { version = "0.22.1", path = "crates/oxc_diagnostics" } -oxc_index = { version = "0.22.1", path = "crates/oxc_index" } -oxc_minifier = { version = "0.22.1", path = "crates/oxc_minifier" } -oxc_mangler = { version = "0.22.1", path = "crates/oxc_mangler" } -oxc_parser = { version = "0.22.1", path = "crates/oxc_parser" } -oxc_semantic = { version = "0.22.1", path = "crates/oxc_semantic" } -oxc_span = { version = "0.22.1", path = "crates/oxc_span" } -oxc_syntax = { version = "0.22.1", path = "crates/oxc_syntax" } -oxc_transformer = { version = "0.22.1", path = "crates/oxc_transformer" } -oxc_sourcemap = { version = "0.22.1", path = "crates/oxc_sourcemap" } -oxc_ast_macros = { version = "0.22.1", path = "crates/oxc_ast_macros" } -oxc_traverse = { version = "0.22.1", path = "crates/oxc_traverse" } -oxc_module_lexer = { version = "0.22.1", path = "crates/oxc_module_lexer" } -oxc_cfg = { version = "0.22.1", path = "crates/oxc_cfg" } -oxc_isolated_declarations = { version = "0.22.1", path = "crates/oxc_isolated_declarations" } -oxc_transform_napi = { version = "0.22.1", path = "napi/transform" } +oxc = { version = "0.23.0", path = "crates/oxc" } +oxc_allocator = { version = "0.23.0", path = "crates/oxc_allocator" } +oxc_ast = { version = "0.23.0", path = "crates/oxc_ast" } +oxc_codegen = { version = "0.23.0", path = "crates/oxc_codegen" } +oxc_diagnostics = { version = "0.23.0", path = "crates/oxc_diagnostics" } +oxc_index = { version = "0.23.0", path = "crates/oxc_index" } +oxc_minifier = { version = "0.23.0", path = "crates/oxc_minifier" } +oxc_mangler = { version = "0.23.0", path = "crates/oxc_mangler" } +oxc_parser = { version = "0.23.0", path = "crates/oxc_parser" } +oxc_semantic = { version = "0.23.0", path = "crates/oxc_semantic" } +oxc_span = { version = "0.23.0", path = "crates/oxc_span" } +oxc_syntax = { version = "0.23.0", path = "crates/oxc_syntax" } +oxc_transformer = { version = "0.23.0", path = "crates/oxc_transformer" } +oxc_sourcemap = { version = "0.23.0", path = "crates/oxc_sourcemap" } +oxc_ast_macros = { version = "0.23.0", path = "crates/oxc_ast_macros" } +oxc_traverse = { version = "0.23.0", path = "crates/oxc_traverse" } +oxc_module_lexer = { version = "0.23.0", path = "crates/oxc_module_lexer" } +oxc_cfg = { version = "0.23.0", path = "crates/oxc_cfg" } +oxc_isolated_declarations = { version = "0.23.0", path = "crates/oxc_isolated_declarations" } +oxc_transform_napi = { version = "0.23.0", path = "napi/transform" } # publish = false oxc_macros = { path = "crates/oxc_macros" } diff --git a/crates/oxc/Cargo.toml b/crates/oxc/Cargo.toml index 7d713ecc3a641..3866c6d23ace0 100644 --- a/crates/oxc/Cargo.toml +++ b/crates/oxc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_allocator/CHANGELOG.md b/crates/oxc_allocator/CHANGELOG.md index a68167d98cad4..5436c75e7c2c1 100644 --- a/crates/oxc_allocator/CHANGELOG.md +++ b/crates/oxc_allocator/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +### Performance + +- 4c6d19d allocator: Use capacity hint (#4584) (Luca Bruno) + ## [0.22.0] - 2024-07-23 ### Refactor diff --git a/crates/oxc_allocator/Cargo.toml b/crates/oxc_allocator/Cargo.toml index c0e88f75b1a61..5accbe7bd44ed 100644 --- a/crates/oxc_allocator/Cargo.toml +++ b/crates/oxc_allocator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_allocator" -version = "0.22.1" +version = "0.23.0" authors.workspace = true description.workspace = true edition.workspace = true diff --git a/crates/oxc_ast/CHANGELOG.md b/crates/oxc_ast/CHANGELOG.md index 23d8a9f516eb1..a660f63be9686 100644 --- a/crates/oxc_ast/CHANGELOG.md +++ b/crates/oxc_ast/CHANGELOG.md @@ -4,6 +4,27 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +### Features + +- 35654e6 codegen: Align operator precedence with esbuild (#4509) (Boshen) +- b952942 linter: Add eslint/no-unused-vars (⭐ attempt 3.2) (#4445) (DonIsaac) +- 85e8418 linter: Add react/jsx-curly-brace-presence (#3949) (Don Isaac) + +### Bug Fixes + +- d5c4b19 parser: Fix enum member parsing (#4543) (DonIsaac) + +### Performance + +- c9c38a1 parser: Support peeking over bytes (#4304) (lucab) + +### Documentation + +- 0914e47 ast: Add doc comments to literal nodes (#4551) (DonIsaac) +- c6a11be ast: Auto-generate doc comments for AstBuilder methods (#4471) (DonIsaac) + ## [0.22.1] - 2024-07-27 ### Features diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index 790b7a0ed5f89..2207cdf73f945 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_ast" -version = "0.22.1" +version = "0.23.0" authors.workspace = true description.workspace = true edition.workspace = true diff --git a/crates/oxc_ast_macros/Cargo.toml b/crates/oxc_ast_macros/Cargo.toml index 98ca4dcd546da..a3e385db998b8 100644 --- a/crates/oxc_ast_macros/Cargo.toml +++ b/crates/oxc_ast_macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_ast_macros" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_cfg/Cargo.toml b/crates/oxc_cfg/Cargo.toml index fc15f25142508..5d6567c98e5c3 100644 --- a/crates/oxc_cfg/Cargo.toml +++ b/crates/oxc_cfg/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_cfg" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_codegen/CHANGELOG.md b/crates/oxc_codegen/CHANGELOG.md index 6e47b8c00e3b9..8ebcf1fe0cf28 100644 --- a/crates/oxc_codegen/CHANGELOG.md +++ b/crates/oxc_codegen/CHANGELOG.md @@ -4,6 +4,29 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +- 27fd062 sourcemap: [**BREAKING**] Avoid passing `Result`s (#4541) (overlookmotel) + +### Features + +- a558492 codegen: Implement `BinaryExpressionVisitor` (#4548) (Boshen) +- 7446e98 codegen: Align more esbuild implementations (#4510) (Boshen) +- 35654e6 codegen: Align operator precedence with esbuild (#4509) (Boshen) + +### Bug Fixes + +- b58ed80 codegen: Enable more test cases (#4585) (Boshen) +- 6a94e3f codegen: Fixes for esbuild test cases (#4503) (Boshen) +- d5c4b19 parser: Fix enum member parsing (#4543) (DonIsaac) + +### Performance + +- 7585e16 linter: Remove allocations for string comparisons (#4570) (DonIsaac) + +### Refactor + + ## [0.22.0] - 2024-07-23 ### Bug Fixes diff --git a/crates/oxc_codegen/Cargo.toml b/crates/oxc_codegen/Cargo.toml index 6ace5e0223121..0602bd3f91419 100644 --- a/crates/oxc_codegen/Cargo.toml +++ b/crates/oxc_codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_codegen" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_diagnostics/Cargo.toml b/crates/oxc_diagnostics/Cargo.toml index 9c1ed695d10af..4a68a15b498fd 100644 --- a/crates/oxc_diagnostics/Cargo.toml +++ b/crates/oxc_diagnostics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_diagnostics" -version = "0.22.1" +version = "0.23.0" authors.workspace = true description.workspace = true edition.workspace = true diff --git a/crates/oxc_index/Cargo.toml b/crates/oxc_index/Cargo.toml index 27a6552458607..0e5190f5a7ecc 100644 --- a/crates/oxc_index/Cargo.toml +++ b/crates/oxc_index/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_index" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_isolated_declarations/CHANGELOG.md b/crates/oxc_isolated_declarations/CHANGELOG.md index 3983860dac9d7..a9c544114b7b2 100644 --- a/crates/oxc_isolated_declarations/CHANGELOG.md +++ b/crates/oxc_isolated_declarations/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +### Bug Fixes + +- d5c4b19 parser: Fix enum member parsing (#4543) (DonIsaac) + ## [0.22.0] - 2024-07-23 ### Bug Fixes diff --git a/crates/oxc_isolated_declarations/Cargo.toml b/crates/oxc_isolated_declarations/Cargo.toml index 1afa669780b52..8081e49895a68 100644 --- a/crates/oxc_isolated_declarations/Cargo.toml +++ b/crates/oxc_isolated_declarations/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_isolated_declarations" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs b/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs index c08ae765119cf..27871f7937a1e 100644 --- a/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs +++ b/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs @@ -110,11 +110,11 @@ fn resolve_global_binding<'a, 'b: 'a>( Some(Expression::Identifier(parent_ident)) if parent_ident.name != ident.name => { - resolve_global_binding(parent_ident, decl_scope, ctx) + return resolve_global_binding(parent_ident, decl_scope, ctx) } // handles "let a = globalThis.JSON; let b = a; a();" Some(parent_expr) if parent_expr.is_member_expression() => { - global_this_member(parent_expr.to_member_expression()) + return global_this_member(parent_expr.to_member_expression()) } _ => None, } diff --git a/crates/oxc_mangler/Cargo.toml b/crates/oxc_mangler/Cargo.toml index 39b166787a6a4..efa62c3ded02c 100644 --- a/crates/oxc_mangler/Cargo.toml +++ b/crates/oxc_mangler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_mangler" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_minifier/CHANGELOG.md b/crates/oxc_minifier/CHANGELOG.md index 1f7202cc21dcc..d299532ffc41f 100644 --- a/crates/oxc_minifier/CHANGELOG.md +++ b/crates/oxc_minifier/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +### Features + +- a558492 codegen: Implement `BinaryExpressionVisitor` (#4548) (Boshen) + +### Bug Fixes + +- 6a94e3f codegen: Fixes for esbuild test cases (#4503) (Boshen) + ## [0.22.0] - 2024-07-23 ### Features diff --git a/crates/oxc_minifier/Cargo.toml b/crates/oxc_minifier/Cargo.toml index e8e11f075f642..7ba373011bfb0 100644 --- a/crates/oxc_minifier/Cargo.toml +++ b/crates/oxc_minifier/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_minifier" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_module_lexer/Cargo.toml b/crates/oxc_module_lexer/Cargo.toml index fb95a293679b6..0f7e259e26834 100644 --- a/crates/oxc_module_lexer/Cargo.toml +++ b/crates/oxc_module_lexer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_module_lexer" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_parser/CHANGELOG.md b/crates/oxc_parser/CHANGELOG.md index 2546b49d8ba7b..a0879383418a8 100644 --- a/crates/oxc_parser/CHANGELOG.md +++ b/crates/oxc_parser/CHANGELOG.md @@ -4,6 +4,42 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +### Features + +- 7446e98 codegen: Align more esbuild implementations (#4510) (Boshen) +- 35654e6 codegen: Align operator precedence with esbuild (#4509) (Boshen) + +### Bug Fixes + +- d5c4b19 parser: Fix enum member parsing (#4543) (DonIsaac) + +### Performance + +- 55a8763 parser: Faster decoding unicode escapes in identifiers (#4579) (overlookmotel) +- ae1d38f parser: Fast path for ASCII when checking char after numeric literal (#4577) (overlookmotel) +- 56ae615 parser: Make not at EOF the hot path in `Source` methods (#4576) (overlookmotel) +- 25679e6 parser: Optimize `Lexer::hex_digit` (#4572) (overlookmotel) +- bb33bcc parser: Speed up lexing non-decimal numbers (#4571) (overlookmotel) +- ab8509e parser: Use `-` not `saturating_sub` (#4561) (overlookmotel) +- c9c38a1 parser: Support peeking over bytes (#4304) (lucab) +- 0870ee1 parser: Get and check lookahead token (#4534) (lucab) + +### Refactor + +- e68ed62 parser: Convert lexer byte handler for `|` to a single match (#4575) (overlookmotel) +- bba824b parser: Convert `Lexer::read_minus` to a single match (#4574) (overlookmotel) +- ef5418a parser: Convert `Lexer::read_left_angle` to a single match (#4573) (overlookmotel) +- 9e5be78 parser: Add `Lexer::consume_2_chars` (#4569) (overlookmotel) +- 649913e parser: Extract `u8` not `&u8` when iterating over bytes (#4568) (overlookmotel) +- 59f00c0 parser: Rename function (#4566) (overlookmotel) +- 8e3e910 parser: Rename vars (#4565) (overlookmotel) +- 0c0601f parser: Rename function (#4564) (overlookmotel) +- 0acc4a7 parser: Fetch 2 bytes in `?` byte handler (#4563) (overlookmotel) +- 565eccf parser: Shorten lexer code (#4562) (overlookmotel) +- 148bdb5 parser: Adjust function inlining (#4530) (overlookmotel) + ## [0.22.1] - 2024-07-27 ### Performance diff --git a/crates/oxc_parser/Cargo.toml b/crates/oxc_parser/Cargo.toml index 7001a62d3ab10..741fd79c628a9 100644 --- a/crates/oxc_parser/Cargo.toml +++ b/crates/oxc_parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_parser" -version = "0.22.1" +version = "0.23.0" authors.workspace = true description.workspace = true edition.workspace = true diff --git a/crates/oxc_semantic/CHANGELOG.md b/crates/oxc_semantic/CHANGELOG.md index 061f10a0fceb7..1fd41e9fafd71 100644 --- a/crates/oxc_semantic/CHANGELOG.md +++ b/crates/oxc_semantic/CHANGELOG.md @@ -4,6 +4,25 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +### Features + +- b952942 linter: Add eslint/no-unused-vars (⭐ attempt 3.2) (#4445) (DonIsaac) +- cf1854b semantic: Remove `ReferenceFlags::Value` from non-type-only exports that referenced type binding (#4511) (Dunqing) + +### Bug Fixes + +- d5c4b19 parser: Fix enum member parsing (#4543) (DonIsaac) + +### Refactor + +- 16c7b98 semantic: Move CatchClause scope binding logic to visit_block_statement (#4505) (Dunqing) +- d6974d4 semantic: `AstNodeParentIter` fetch nodes lazily (#4533) (overlookmotel) +- d914b14 semantic: Reusing the same reference (#4529) (Dunqing) +- 7b5e1f5 semantic: Use `is_empty()` instead of `len() == 0` (#4532) (overlookmotel) +- 9db4259 semantic: Inline trivial methods (#4531) (overlookmotel) + ## [0.22.1] - 2024-07-27 ### Features diff --git a/crates/oxc_semantic/Cargo.toml b/crates/oxc_semantic/Cargo.toml index 22a45ba11b64a..c4e5bef2ecc3a 100644 --- a/crates/oxc_semantic/Cargo.toml +++ b/crates/oxc_semantic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_semantic" -version = "0.22.1" +version = "0.23.0" authors.workspace = true description.workspace = true edition.workspace = true diff --git a/crates/oxc_sourcemap/CHANGELOG.md b/crates/oxc_sourcemap/CHANGELOG.md index 812ac305e3cbc..f45d496cc51d4 100644 --- a/crates/oxc_sourcemap/CHANGELOG.md +++ b/crates/oxc_sourcemap/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +- 27fd062 sourcemap: [**BREAKING**] Avoid passing `Result`s (#4541) (overlookmotel) + +### Performance + +- d00014e sourcemap: Elide bounds checks in VLQ encoding (#4583) (overlookmotel) +- 1fd9dd0 sourcemap: Use simd to escape JSON string (#4487) (Brooooooklyn) + +### Refactor + +- 7c42ffc sourcemap: Align Base64 chars lookup table to cache line (#4535) (overlookmotel) + ## [0.22.1] - 2024-07-27 ### Bug Fixes diff --git a/crates/oxc_sourcemap/Cargo.toml b/crates/oxc_sourcemap/Cargo.toml index 0532b8ab55489..acd59782d030a 100644 --- a/crates/oxc_sourcemap/Cargo.toml +++ b/crates/oxc_sourcemap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_sourcemap" -version = "0.22.1" +version = "0.23.0" authors.workspace = true description.workspace = true edition.workspace = true diff --git a/crates/oxc_sourcemap/src/encode.rs b/crates/oxc_sourcemap/src/encode.rs index b1910d708da1a..90ebfce78a0a6 100644 --- a/crates/oxc_sourcemap/src/encode.rs +++ b/crates/oxc_sourcemap/src/encode.rs @@ -112,6 +112,9 @@ fn serialize_sourcemap_mappings(sm: &SourceMap) -> String { ) } +// Max length of a single VLQ encoding +const MAX_VLQ_BYTES: usize = 7; + fn serialize_mappings(tokens: &[Token], token_chunk: &TokenChunk) -> String { let TokenChunk { start, @@ -129,33 +132,48 @@ fn serialize_mappings(tokens: &[Token], token_chunk: &TokenChunk) -> String { let mut rv = String::with_capacity(capacity); for (idx, token) in tokens[start as usize..end as usize].iter().enumerate() { + // Max length of a single VLQ encoding is 7 bytes. Max number of calls to `encode_vlq_diff` is 5. + // Also need 1 byte for each line number difference, or 1 byte if no line num difference. + // Reserve this amount of capacity in `rv` early, so can skip bounds checks in code below. + // As well as skipping the bounds checks, this also removes a function call to + // `alloc::raw_vec::RawVec::grow_one` for every byte that's pushed. + // https://godbolt.org/z/44G8jjss3 + const MAX_TOTAL_VLQ_BYTES: usize = 5 * MAX_VLQ_BYTES; + + let num_line_breaks = token.get_dst_line() - prev_dst_line; let index = start as usize + idx; - if token.get_dst_line() != prev_dst_line { + if num_line_breaks != 0 { + rv.reserve(MAX_TOTAL_VLQ_BYTES + num_line_breaks as usize); + // SAFETY: We have reserved sufficient capacity for `num_line_breaks` bytes + unsafe { push_bytes_unchecked(&mut rv, b';', num_line_breaks) }; prev_dst_col = 0; - while token.get_dst_line() != prev_dst_line { - rv.push(';'); - prev_dst_line += 1; - } + prev_dst_line += num_line_breaks; } else if index > 0 { if Some(token) == tokens.get(index - 1) { continue; } - rv.push(','); + rv.reserve(MAX_TOTAL_VLQ_BYTES + 1); + // SAFETY: We have reserved sufficient capacity for 1 byte + unsafe { push_byte_unchecked(&mut rv, b',') }; } - encode_vlq_diff(&mut rv, token.get_dst_col(), prev_dst_col); - prev_dst_col = token.get_dst_col(); - - if let Some(source_id) = token.get_source_id() { - encode_vlq_diff(&mut rv, source_id, prev_source_id); - prev_source_id = source_id; - encode_vlq_diff(&mut rv, token.get_src_line(), prev_src_line); - prev_src_line = token.get_src_line(); - encode_vlq_diff(&mut rv, token.get_src_col(), prev_src_col); - prev_src_col = token.get_src_col(); - if let Some(name_id) = token.get_name_id() { - encode_vlq_diff(&mut rv, name_id, prev_name_id); - prev_name_id = name_id; + // SAFETY: We have reserved enough capacity above to satisfy safety contract + // of `encode_vlq_diff` for all calls below + unsafe { + encode_vlq_diff(&mut rv, token.get_dst_col(), prev_dst_col); + prev_dst_col = token.get_dst_col(); + + if let Some(source_id) = token.get_source_id() { + encode_vlq_diff(&mut rv, source_id, prev_source_id); + prev_source_id = source_id; + encode_vlq_diff(&mut rv, token.get_src_line(), prev_src_line); + prev_src_line = token.get_src_line(); + encode_vlq_diff(&mut rv, token.get_src_col(), prev_src_col); + prev_src_col = token.get_src_col(); + if let Some(name_id) = token.get_name_id() { + encode_vlq_diff(&mut rv, name_id, prev_name_id); + prev_name_id = name_id; + } } } } @@ -163,8 +181,14 @@ fn serialize_mappings(tokens: &[Token], token_chunk: &TokenChunk) -> String { rv } +/// Encode diff as VLQ and push encoding into `out`. +/// Will push between 1 byte (num = 0) and 7 bytes (num = -u32::MAX). +/// +/// # SAFETY +/// Caller must ensure at least 7 bytes spare capacity in `out`, +/// as this function does not perform any bounds checks. #[inline] -fn encode_vlq_diff(out: &mut String, a: u32, b: u32) { +unsafe fn encode_vlq_diff(out: &mut String, a: u32, b: u32) { encode_vlq(out, i64::from(a) - i64::from(b)); } @@ -179,21 +203,87 @@ static B64_CHARS: Aligned64 = Aligned64([ b'w', b'x', b'y', b'z', b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'+', b'/', ]); -#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] -fn encode_vlq(out: &mut String, num: i64) { +/// Encode number as VLQ and push encoding into `out`. +/// Will push between 1 byte (num = 0) and 7 bytes (num = -u32::MAX). +/// +/// # SAFETY +/// Caller must ensure at least 7 bytes spare capacity in `out`, +/// as this function does not perform any bounds checks. +#[allow( + clippy::cast_possible_truncation, + clippy::cast_sign_loss, + clippy::unnecessary_safety_comment +)] +unsafe fn encode_vlq(out: &mut String, num: i64) { let mut num = if num < 0 { ((-num) << 1) + 1 } else { num << 1 }; + // Breaking out of loop early when have reached last char (rather than conditionally adding + // 32 for last char within the loop) removes 3 instructions from the loop. + // https://godbolt.org/z/Es4Pavh9j + // This translates to a 16% speed-up for VLQ encoding. + let mut digit; loop { - let mut digit = num & 0b11111; + digit = num & 0b11111; num >>= 5; - if num > 0 { - digit |= 1 << 5; - } - out.push(B64_CHARS.0[digit as usize] as char); if num == 0 { break; } + + let b = B64_CHARS.0[digit as usize + 32]; + // SAFETY: + // * This loop can execute a maximum of 7 times, and on last turn will exit before getting here. + // Caller promises there are at least 7 bytes spare capacity in `out` at start. We only + // push 1 byte on each turn, so guaranteed there is at least 1 byte capacity in `out` here. + // * All values in `B64_CHARS` lookup table are ASCII bytes. + push_byte_unchecked(out, b); + } + + let b = B64_CHARS.0[digit as usize]; + // SAFETY: + // * The loop above pushes max 6 bytes. Caller promises there are at least 7 bytes spare capacity + // in `out` at start. So guaranteed there is at least 1 byte capacity in `out` here. + // * All values in `B64_CHARS` lookup table are ASCII bytes. + push_byte_unchecked(out, b); +} + +/// Push a byte to `out` without bounds checking. +/// +/// # SAFETY +/// * `out` must have at least 1 byte spare capacity. +/// * `b` must be an ASCII byte (i.e. not `>= 128`). +// +// `#[inline(always)]` to ensure that `len` is stored in a register during `encode_vlq`'s loop. +#[allow(clippy::inline_always)] +#[inline(always)] +unsafe fn push_byte_unchecked(out: &mut String, b: u8) { + debug_assert!(out.len() < out.capacity()); + debug_assert!(b.is_ascii()); + + let out = out.as_mut_vec(); + let len = out.len(); + let ptr = out.as_mut_ptr().add(len); + ptr.write(b); + out.set_len(len + 1); +} + +/// Push a byte to `out` a number of times without bounds checking. +/// +/// # SAFETY +/// * `out` must have at least `repeats` bytes spare capacity. +/// * `b` must be an ASCII byte (i.e. not `>= 128`). +#[inline] +unsafe fn push_bytes_unchecked(out: &mut String, b: u8, repeats: u32) { + debug_assert!(out.capacity() - out.len() >= repeats as usize); + debug_assert!(b.is_ascii()); + + let out = out.as_mut_vec(); + let len = out.len(); + let mut ptr = out.as_mut_ptr().add(len); + for _ in 0..repeats { + ptr.write(b); + ptr = ptr.add(1); } + out.set_len(len + repeats as usize); } /// A helper for pre-allocate string buffer. @@ -313,3 +403,51 @@ fn test_encode_escape_string() { r#"{"version":3,"names":["name_length_greater_than_16_\u0000"],"sources":["\u0000"],"sourcesContent":["emoji-👀-\u0000"],"x_google_ignoreList":[0],"mappings":""}"# ); } + +#[test] +fn test_vlq_encode_diff() { + // Most import tests here are that with maximum values, `encode_vlq_diff` pushes maximum of 7 bytes. + // This invariant is essential to safety of `encode_vlq_diff`. + #[rustfmt::skip] + const FIXTURES: &[(u32, u32, &str)] = &[ + (0, 0, "A"), + (1, 0, "C"), + (2, 0, "E"), + (15, 0, "e"), + (16, 0, "gB"), + (511, 0, "+f"), + (512, 0, "ggB"), + (16_383, 0, "+/f"), + (16_384, 0, "gggB"), + (524_287, 0, "+//f"), + (524_288, 0, "ggggB"), + (16_777_215, 0, "+///f"), + (16_777_216, 0, "gggggB"), + (536_870_911, 0, "+////f"), + (536_870_912, 0, "ggggggB"), + (u32::MAX, 0, "+/////H"), // 7 bytes + + (0, 1, "D"), + (0, 2, "F"), + (0, 15, "f"), + (0, 16, "hB"), + (0, 511, "/f"), + (0, 512, "hgB"), + (0, 16_383, "//f"), + (0, 16_384, "hggB"), + (0, 524_287, "///f"), + (0, 524_288, "hgggB"), + (0, 16_777_215, "////f"), + (0, 16_777_216, "hggggB"), + (0, 536_870_911, "/////f"), + (0, 536_870_912, "hgggggB"), + (0, u32::MAX, "//////H"), // 7 bytes + ]; + + for (a, b, res) in FIXTURES.iter().copied() { + let mut out = String::with_capacity(MAX_VLQ_BYTES); + // SAFETY: `out` has 7 bytes spare capacity + unsafe { encode_vlq_diff(&mut out, a, b) }; + assert_eq!(&out, res); + } +} diff --git a/crates/oxc_span/Cargo.toml b/crates/oxc_span/Cargo.toml index 2d826deaa7a84..6dd803b439449 100644 --- a/crates/oxc_span/Cargo.toml +++ b/crates/oxc_span/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_span" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_syntax/CHANGELOG.md b/crates/oxc_syntax/CHANGELOG.md index d0943fe4dea70..3cbd66ef9c74c 100644 --- a/crates/oxc_syntax/CHANGELOG.md +++ b/crates/oxc_syntax/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +### Features + +- a558492 codegen: Implement `BinaryExpressionVisitor` (#4548) (Boshen) +- 35654e6 codegen: Align operator precedence with esbuild (#4509) (Boshen) +- b952942 linter: Add eslint/no-unused-vars (⭐ attempt 3.2) (#4445) (DonIsaac) + ## [0.22.1] - 2024-07-27 ### Bug Fixes diff --git a/crates/oxc_syntax/Cargo.toml b/crates/oxc_syntax/Cargo.toml index e87add00751ff..f4898d6d77e10 100644 --- a/crates/oxc_syntax/Cargo.toml +++ b/crates/oxc_syntax/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_syntax" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_transformer/CHANGELOG.md b/crates/oxc_transformer/CHANGELOG.md index 557807aa8e43a..98e0a4d2aa363 100644 --- a/crates/oxc_transformer/CHANGELOG.md +++ b/crates/oxc_transformer/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +### Bug Fixes + +- d5c4b19 parser: Fix enum member parsing (#4543) (DonIsaac) + +### Refactor + +- 96602bf transformer/typescript: Determine whether to remove `ExportSpeicifer` by `ReferenceFlags` (#4513) (Dunqing) + ## [0.22.1] - 2024-07-27 ### Bug Fixes diff --git a/crates/oxc_transformer/Cargo.toml b/crates/oxc_transformer/Cargo.toml index 80be29770bac3..4c4819d4ed5d7 100644 --- a/crates/oxc_transformer/Cargo.toml +++ b/crates/oxc_transformer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_transformer" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/crates/oxc_traverse/CHANGELOG.md b/crates/oxc_traverse/CHANGELOG.md index 8bbb2d596dd5f..331c5ce0647dc 100644 --- a/crates/oxc_traverse/CHANGELOG.md +++ b/crates/oxc_traverse/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0. +## [0.23.0] - 2024-08-01 + +### Bug Fixes + +- d5c4b19 parser: Fix enum member parsing (#4543) (DonIsaac) + +### Refactor + +- e6a8af6 traverse: Speed up tests (#4538) (overlookmotel) + ## [0.22.1] - 2024-07-27 ### Bug Fixes diff --git a/crates/oxc_traverse/Cargo.toml b/crates/oxc_traverse/Cargo.toml index b015e1885db5c..d5cd46c52baf7 100644 --- a/crates/oxc_traverse/Cargo.toml +++ b/crates/oxc_traverse/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_traverse" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/napi/transform/Cargo.toml b/napi/transform/Cargo.toml index 2bc558aeab411..7a53ae07c6c4a 100644 --- a/napi/transform/Cargo.toml +++ b/napi/transform/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxc_transform_napi" -version = "0.22.1" +version = "0.23.0" publish = true authors.workspace = true description.workspace = true diff --git a/npm/oxc-parser/package.json b/npm/oxc-parser/package.json index 993bc8bfae63a..df2a9fa7a3fd1 100644 --- a/npm/oxc-parser/package.json +++ b/npm/oxc-parser/package.json @@ -1,6 +1,6 @@ { "name": "oxc-parser", - "version": "0.22.1", + "version": "0.23.0", "description": "Oxc Parser Node API", "keywords": [ "Parser" diff --git a/npm/oxc-transform/package.json b/npm/oxc-transform/package.json index 86d38e5694143..bdacda69187b8 100644 --- a/npm/oxc-transform/package.json +++ b/npm/oxc-transform/package.json @@ -1,6 +1,6 @@ { "name": "oxc-transform", - "version": "0.22.1", + "version": "0.23.0", "description": "Oxc transform Node API", "keywords": [ "transform" diff --git a/wasm/parser/package.json b/wasm/parser/package.json index 9ecfcffca61d3..cbc2b4f0f0994 100644 --- a/wasm/parser/package.json +++ b/wasm/parser/package.json @@ -1,6 +1,6 @@ { "name": "@oxc-parser/wasm", - "version": "0.22.1", + "version": "0.23.0", "description": "Wasm target for the oxc parser.", "keywords": [ "JavaScript",