swc_coverage_instrument/options/
instrument_options.rs

1use istanbul_oxide::SourceMap;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
5#[serde(rename_all = "camelCase", default)]
6pub struct InstrumentLogOptions {
7    pub level: Option<String>,
8    pub enable_trace: bool,
9}
10
11impl Default for InstrumentLogOptions {
12    fn default() -> Self {
13        InstrumentLogOptions {
14            level: None,
15            enable_trace: false,
16        }
17    }
18}
19
20#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
21#[serde(rename_all = "camelCase", default)]
22pub struct InstrumentOptions {
23    pub coverage_variable: String,
24    pub compact: bool,
25    pub report_logic: bool,
26    pub ignore_class_methods: Vec<String>,
27    pub input_source_map: Option<SourceMap>,
28    pub instrument_log: InstrumentLogOptions,
29    pub debug_initial_coverage_comment: bool,
30    // Allow to specify which files should be excluded from instrumentation.
31    // This option accepts an array of wax(https://crates.io/crates/wax)-compatible glob patterns
32    // and will match against the filename provided by swc's core.
33    pub unstable_exclude: Option<Vec<String>>,
34}
35
36impl Default for InstrumentOptions {
37    fn default() -> Self {
38        InstrumentOptions {
39            coverage_variable: "__coverage__".to_string(),
40            compact: false,
41            report_logic: false,
42            ignore_class_methods: Default::default(),
43            input_source_map: Default::default(),
44            instrument_log: Default::default(),
45            debug_initial_coverage_comment: false,
46            unstable_exclude: Default::default(),
47        }
48    }
49}