fix(es): Fix a crash related to source map (#7307)

**Related issue:**

 - Reverts #7229.
 - Closes #7301.
This commit is contained in:
Donny/강동윤 2023-04-21 12:58:24 +09:00 committed by GitHub
parent c8e6774070
commit e7f7b01f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

8
Cargo.lock generated
View File

@ -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",

View File

@ -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() {

View File

@ -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