swc_ecma_minifier/
mode.rs

1use swc_ecma_ast::*;
2
3pub(crate) trait Mode: Send + Sync {
4    fn store(&self, id: Id, value: &Expr);
5
6    fn preserve_vars(&self) -> bool;
7
8    fn should_be_very_correct(&self) -> bool;
9
10    /// If this returns true, template literals with `\n` or `\r` will be
11    /// converted to [Lit::Str].
12    fn force_str_for_tpl(&self) -> bool;
13}
14
15pub struct Minification;
16
17impl Mode for Minification {
18    fn store(&self, _: Id, _: &Expr) {}
19
20    fn preserve_vars(&self) -> bool {
21        false
22    }
23
24    fn should_be_very_correct(&self) -> bool {
25        true
26    }
27
28    fn force_str_for_tpl(&self) -> bool {
29        false
30    }
31}