Skip to content

Commit c1405da

Browse files
authored
feat(es/compiler): Merge private_in_object and static_blocks (#10909)
**Description:** The visitor pattern, which is used by SWC, has noticeable overhead and noticeable impact on the binary size. So I'm planning to merge most of the AST transforms into a single `Compiler` type. This is the first step for the merging. API will not change during this merging process.
1 parent 5fde348 commit c1405da

File tree

11 files changed

+764
-624
lines changed

11 files changed

+764
-624
lines changed

.changeset/khaki-avocados-poke.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
swc_ecma_compiler: patch
3+
swc_ecma_compat_es2022: patch
4+
swc_core: patch
5+
---
6+
7+
feat(es/compiler): Merge `private_in_object` and `static_blocks`

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/swc_ecma_compat_es2022/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ swc_atoms = { version = "7.0.0", path = "../swc_atoms" }
2121
swc_common = { version = "14.0.1", path = "../swc_common" }
2222
swc_ecma_ast = { version = "14.0.0", path = "../swc_ecma_ast" }
2323
swc_ecma_compat_common = { version = "19.0.0", path = "../swc_ecma_compat_common" }
24+
swc_ecma_compiler = { version = "0.1.0", path = "../swc_ecma_compiler" }
2425
swc_ecma_transforms_base = { version = "22.0.0", path = "../swc_ecma_transforms_base" }
2526
swc_ecma_transforms_classes = { version = "22.0.0", path = "../swc_ecma_transforms_classes" }
2627
swc_ecma_transforms_macros = { version = "1.0.1", path = "../swc_ecma_transforms_macros" }

crates/swc_ecma_compat_es2022/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use swc_common::Mark;
44
use swc_ecma_ast::Pass;
55
use swc_ecma_compat_common::regexp::{self, regexp};
6+
use swc_ecma_compiler::{Compiler, Features};
67

78
pub use self::{
89
class_properties::class_properties, private_in_object::private_in_object,
@@ -26,9 +27,11 @@ pub fn es2022(config: Config, unresolved_mark: Mark) -> impl Pass {
2627
unicode_regex: false,
2728
unicode_sets_regex: false,
2829
}),
29-
static_blocks(),
30+
Compiler::new(swc_ecma_compiler::Config {
31+
includes: Features::STATIC_BLOCKS | Features::PRIVATE_IN_OBJECT,
32+
excludes: Features::empty(),
33+
}),
3034
class_properties(config.class_properties, unresolved_mark),
31-
private_in_object(),
3235
)
3336
}
3437

0 commit comments

Comments
 (0)