swc_ecma_minifier/
mode.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
30
31
use swc_ecma_ast::*;

pub(crate) trait Mode: Send + Sync {
    fn store(&self, id: Id, value: &Expr);

    fn preserve_vars(&self) -> bool;

    fn should_be_very_correct(&self) -> bool;

    /// If this returns true, template literals with `\n` or `\r` will be
    /// converted to [Lit::Str].
    fn force_str_for_tpl(&self) -> bool;
}

pub struct Minification;

impl Mode for Minification {
    fn store(&self, _: Id, _: &Expr) {}

    fn preserve_vars(&self) -> bool {
        false
    }

    fn should_be_very_correct(&self) -> bool {
        true
    }

    fn force_str_for_tpl(&self) -> bool {
        false
    }
}