Skip to content

Commit

Permalink
refactor: 🔥 remove nested config
Browse files Browse the repository at this point in the history
  • Loading branch information
stormslowly committed May 27, 2024
1 parent 2840d90 commit 02d3ca8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
14 changes: 4 additions & 10 deletions crates/mako/src/build/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,10 @@ impl Context {
let is_ts = file.extname == "ts" || file.extname == "tsx";

let mut assumptions = Assumptions::default();
self.config.js.as_ref().map(|js_config| {
js_config.transform.as_ref().map(|transform_config| {
assumptions.set_public_class_fields |=
!transform_config.use_define_for_class_fields;
if is_ts {
assumptions.set_class_methods |= !transform_config.use_define_for_class_fields;
}
})
});

assumptions.set_public_class_fields |= !self.config.use_define_for_class_fields;
if is_ts {
assumptions.set_class_methods |= !self.config.use_define_for_class_fields;
}
assumptions
}
}
Expand Down
34 changes: 2 additions & 32 deletions crates/mako/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ pub struct Config {
pub rsc_client: Option<RscClientConfig>,
pub experimental: ExperimentalConfig,
pub watch: WatchConfig,
pub js: Option<JsConfig>,
pub use_define_for_class_fields: bool,
}

#[allow(dead_code)]
Expand Down Expand Up @@ -527,34 +527,6 @@ pub struct OptimizeChunkGroup {
#[serde(default, with = "optimize_test_format")]
pub test: Option<Regex>,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct JsConfig {
pub transform: Option<TransformConfig>,
}

impl Default for JsConfig {
fn default() -> Self {
JsConfig {
transform: Some(TransformConfig::default()),
}
}
}

#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct TransformConfig {
#[serde(default)]
pub use_define_for_class_fields: bool,
}

impl Default for TransformConfig {
fn default() -> Self {
TransformConfig {
use_define_for_class_fields: true,
}
}
}

impl Default for OptimizeChunkGroup {
fn default() -> Self {
Expand Down Expand Up @@ -661,9 +633,7 @@ const DEFAULT_CONFIG: &str = r#"
"rscServer": false,
"rscClient": false,
"experimental": { "webpackSyntaxValidate": [] },
"js": {
"useDefineForClassFields": true
},
"useDefineForClassFields": true,
"watch": { "ignorePaths": [] }
}
"#;
Expand Down

0 comments on commit 02d3ca8

Please sign in to comment.