diff --git a/Cargo.lock b/Cargo.lock index 23cef256d0f..b1f99382061 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -372,14 +372,15 @@ dependencies = [ [[package]] name = "browserslist-rs" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2557836820eed97f79071bb3294b2640e71e0bc4301336a210a1b8b4947c15" +checksum = "405bbd46590a441abe5db3e5c8af005aa42e640803fecb51912703e93e4ce8d3" dependencies = [ "ahash 0.8.7", "anyhow", "chrono", "either", + "indexmap 2.1.0", "itertools 0.12.0", "nom", "once_cell", diff --git a/crates/preset_env_base/Cargo.toml b/crates/preset_env_base/Cargo.toml index 26a74bce0ae..0429f33a467 100644 --- a/crates/preset_env_base/Cargo.toml +++ b/crates/preset_env_base/Cargo.toml @@ -13,7 +13,7 @@ bench = false [dependencies] ahash = "0.8.5" anyhow = "1" -browserslist-rs = "0.14.0" +browserslist-rs = "0.15.0" dashmap = "5.4.0" once_cell = "1.18.0" semver = { version = "1.0.17", features = ["serde"] } diff --git a/crates/preset_env_base/src/lib.rs b/crates/preset_env_base/src/lib.rs index 863bc078875..9c5c33470d8 100644 --- a/crates/preset_env_base/src/lib.rs +++ b/crates/preset_env_base/src/lib.rs @@ -72,6 +72,21 @@ pub struct BrowserData { pub bun: T, } +impl BrowserData +where + T: Default, +{ + pub fn insert(&mut self, k: &str, v: T) -> T { + for (key, value) in self.iter_mut() { + if k == key { + return std::mem::replace(value, v); + } + } + + panic!("unknown key: {}", k) + } +} + /// A map of browser names to data for feature support in browser. /// /// This type mainly stores `minimum version for each browsers with support for diff --git a/crates/preset_env_base/src/query.rs b/crates/preset_env_base/src/query.rs index a1e9995b099..fb2183af909 100644 --- a/crates/preset_env_base/src/query.rs +++ b/crates/preset_env_base/src/query.rs @@ -121,6 +121,22 @@ pub fn targets_to_versions(v: Option) -> Result { } } + let mut result = Versions::default(); + for (k, v) in map.iter() { + match v { + QueryOrVersion::Query(q) => { + let v = q.exec().context("failed to run query")?; + + for (k, v) in v { + result.insert(k, v); + } + } + QueryOrVersion::Version(v) => { + result.insert(k, Some(*v)); + } + } + } + unimplemented!("Targets: {:?}", map) } _ => unimplemented!("Option: {:?}", v), diff --git a/crates/swc/tests/fixture/issues-8xxx/8492/input/.swcrc b/crates/swc/tests/fixture/issues-8xxx/8492/input/.swcrc new file mode 100644 index 00000000000..1f07700e11c --- /dev/null +++ b/crates/swc/tests/fixture/issues-8xxx/8492/input/.swcrc @@ -0,0 +1,23 @@ +{ + "jsc": { + "parser": { + "syntax": "ecmascript", + "jsx": false + }, + "loose": false, + "minify": { + "compress": false, + "mangle": false + } + }, + "module": { + "type": "es6" + }, + "minify": false, + "isModule": true, + "env": { + "targets": "ios_saf 14", + "coreJs": "3.21", + "mode": "usage" + } +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-8xxx/8492/input/1.js b/crates/swc/tests/fixture/issues-8xxx/8492/input/1.js new file mode 100644 index 00000000000..2467ae21ae2 --- /dev/null +++ b/crates/swc/tests/fixture/issues-8xxx/8492/input/1.js @@ -0,0 +1,3 @@ +// Doesn't matter +console.log(Promise.resolve) +console.log(globalThis) \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-8xxx/8492/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8492/output/1.js new file mode 100644 index 00000000000..122a607b901 --- /dev/null +++ b/crates/swc/tests/fixture/issues-8xxx/8492/output/1.js @@ -0,0 +1,2 @@ +console.log(Promise.resolve); +console.log(globalThis);