mirror of
https://github.com/swc-project/swc.git
synced 2024-11-28 11:13:43 +03:00
feat(es/preset-env): Make android targets fall back to chrome (#1597)
This commit is contained in:
parent
731dc68c92
commit
a24266d986
@ -163,21 +163,41 @@ pub fn should_enable(target: Versions, feature: Versions, default: bool) -> bool
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
target
|
target.iter().zip(feature.iter()).any(
|
||||||
.iter()
|
|((target_name, maybe_target_version), (_, maybe_feature_version))| {
|
||||||
.zip(feature.iter())
|
maybe_target_version.map_or(false, |target_version| {
|
||||||
.any(|((_, target_version), (_, f))| {
|
let feature_or_fallback_version =
|
||||||
if target_version.is_none() {
|
maybe_feature_version.or_else(|| match target_name {
|
||||||
return false;
|
// Fall back to Chrome versions if Android browser data
|
||||||
}
|
// is missing from the feature data. It appears the
|
||||||
|
// Android browser has aligned its versioning with Chrome.
|
||||||
|
"android" => feature.chrome,
|
||||||
|
_ => None,
|
||||||
|
});
|
||||||
|
|
||||||
if f.is_none() {
|
feature_or_fallback_version.map_or(true, |v| v > target_version)
|
||||||
return true;
|
})
|
||||||
}
|
},
|
||||||
|
)
|
||||||
let f = f.as_ref().unwrap();
|
}
|
||||||
let target = target_version.unwrap();
|
|
||||||
|
#[cfg(test)]
|
||||||
*f > target
|
mod tests {
|
||||||
})
|
use super::*;
|
||||||
|
use crate::BrowserData;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_enable_android_falls_back_to_chrome() {
|
||||||
|
assert!(!should_enable(
|
||||||
|
BrowserData {
|
||||||
|
android: Some("51.0.0".parse().unwrap()),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
BrowserData {
|
||||||
|
chrome: Some("51.0.0".parse().unwrap()),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
false
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user