diff --git a/Cargo.lock b/Cargo.lock index 30697fedb7ac..08a1fda5c1dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1343,9 +1343,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "h2" -version = "0.3.15" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" dependencies = [ "bytes", "fnv", @@ -1481,9 +1481,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.23" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", diff --git a/bindings/swc_cli/src/commands/compile.rs b/bindings/swc_cli/src/commands/compile.rs index ee517be4df5f..18c94e6db688 100644 --- a/bindings/swc_cli/src/commands/compile.rs +++ b/bindings/swc_cli/src/commands/compile.rs @@ -545,8 +545,10 @@ fn extend_source_map( let mut source_map = sourcemap::SourceMap::from_reader(source_map.as_bytes()) .context("failed to encode source map")?; - if let Some(ref source_file_name) = source_file_name { - source_map.set_source(0u32, source_file_name); + if !source_map.get_token_count() != 0 { + if let Some(ref source_file_name) = source_file_name { + source_map.set_source(0u32, source_file_name); + } } if source_root.is_some() { diff --git a/crates/swc/src/lib.rs b/crates/swc/src/lib.rs index d0a70b8e7689..1942e1e8a07d 100644 --- a/crates/swc/src/lib.rs +++ b/crates/swc/src/lib.rs @@ -558,7 +558,7 @@ impl Compiler { let (code, map) = match source_map { SourceMapsConfig::Bool(v) => { - if v && !src_map_buf.is_empty() { + if v { let mut buf = vec![]; self.cm