swc_ecma_compat_es2022/
lib.rs

1#![allow(clippy::vec_box)]
2
3use swc_common::Mark;
4use swc_ecma_ast::Pass;
5use swc_ecma_compat_common::regexp::{self, regexp};
6use swc_ecma_compiler::{Compiler, Features};
7
8pub use self::{
9    class_properties::class_properties, private_in_object::private_in_object,
10    static_blocks::static_blocks,
11};
12
13pub mod class_properties;
14pub mod optional_chaining_impl;
15pub mod private_in_object;
16pub mod static_blocks;
17
18pub fn es2022(config: Config, unresolved_mark: Mark) -> impl Pass {
19    (
20        regexp(regexp::Config {
21            dot_all_regex: true,
22            has_indices: true,
23            lookbehind_assertion: true,
24            named_capturing_groups_regex: true,
25            sticky_regex: false,
26            unicode_property_regex: true,
27            unicode_regex: false,
28            unicode_sets_regex: false,
29        }),
30        Compiler::new(swc_ecma_compiler::Config {
31            includes: Features::STATIC_BLOCKS | Features::PRIVATE_IN_OBJECT,
32            ..Default::default()
33        }),
34        class_properties(config.class_properties, unresolved_mark),
35    )
36}
37
38#[derive(Debug, Clone, Default)]
39pub struct Config {
40    pub class_properties: class_properties::Config,
41}