swc_ecma_compat_es2020/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use serde::Deserialize;
use swc_common::Mark;
use swc_ecma_ast::Pass;

pub use self::{
    export_namespace_from::export_namespace_from, nullish_coalescing::nullish_coalescing,
    optional_chaining::optional_chaining,
};

mod export_namespace_from;
pub mod nullish_coalescing;
pub mod optional_chaining;

pub fn es2020(config: Config, unresolved_mark: Mark) -> impl Pass {
    (
        nullish_coalescing(config.nullish_coalescing),
        optional_chaining(config.optional_chaining, unresolved_mark),
        export_namespace_from(),
    )
}

#[derive(Debug, Clone, Default, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Config {
    #[serde(flatten)]
    pub nullish_coalescing: nullish_coalescing::Config,
    #[serde(flatten)]
    pub optional_chaining: optional_chaining::Config,
}