Skip to content

Commit

Permalink
chore(deps): Update base64 to v0.21 (#8369)
Browse files Browse the repository at this point in the history
  • Loading branch information
Redfire75369 authored Dec 2, 2023
1 parent 79966b9 commit c2d1a6c
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 37 deletions.
53 changes: 35 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/swc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ plugin_transform_host_native = [

[dependencies]
anyhow = "1"
base64 = "0.13.0"
base64 = "0.21.0"
dashmap = "5.4.0"
either = "1"
indexmap = { version = "1.9.3", features = ["serde"] }
Expand Down
9 changes: 4 additions & 5 deletions crates/swc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ use std::{

use anyhow::{bail, Context, Error};
use atoms::JsWord;
use base64::prelude::{Engine, BASE64_STANDARD};
use common::{collections::AHashMap, comments::SingleThreadedComments, errors::HANDLER};
use jsonc_parser::{parse_to_serde_value, ParseOptions};
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -265,11 +266,9 @@ impl Compiler {

let content = url.path()[idx + "base64,".len()..].trim();

let res = base64::decode_config(
content.as_bytes(),
base64::Config::new(base64::CharacterSet::Standard, true),
)
.context("failed to decode base64-encoded source map")?;
let res = BASE64_STANDARD
.decode(content.as_bytes())
.context("failed to decode base64-encoded source map")?;

Ok(Some(sourcemap::SourceMap::from_slice(&res).context(
"failed to read input source map from inlined base64 encoded \
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ swc_graph_analyzer = { version = "0.22.12", path = "../swc_graph_a
hex = "0.4"
ntest = "0.7.2"
path-clean = "=0.1.0"
reqwest = { version = "0.11.13", features = ["blocking"] }
reqwest = { version = "0.11.14", features = ["blocking"] }
sha-1 = "0.10"
tempfile = "3.6.0"
url = "2.4.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_compiler_base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ node = ["napi", "napi-derive"]

[dependencies]
anyhow = "1.0.75"
base64 = "0.13.0"
base64 = "0.21.0"
pathdiff = "0.2.0"
serde = { version = "1.0.188", features = ["derive"] }
sourcemap = "6.2"
Expand Down
7 changes: 2 additions & 5 deletions crates/swc_compiler_base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::{
};

use anyhow::{Context, Error};
use base64::prelude::{Engine, BASE64_STANDARD};
use serde::{
de::{Unexpected, Visitor},
Deserialize, Deserializer, Serialize, Serializer,
Expand Down Expand Up @@ -212,11 +213,7 @@ where
let map = String::from_utf8(buf).context("source map is not utf-8")?;

src.push_str("\n//# sourceMappingURL=data:application/json;base64,");
base64::encode_config_buf(
map.as_bytes(),
base64::Config::new(base64::CharacterSet::Standard, true),
&mut src,
);
BASE64_STANDARD.encode_string(map.as_bytes(), &mut src);
(src, None)
}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ swc_ecma_ast = { version = "0.110.11", path = "../swc_ecma_ast" }
swc_ecma_codegen_macros = { version = "0.7.3", path = "../swc_ecma_codegen_macros" }

[dev-dependencies]
base64 = "0.13"
base64 = "0.21"
criterion = "0.5"
serde_json = "1"

Expand Down
3 changes: 2 additions & 1 deletion crates/swc_ecma_codegen/tests/sourcemap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{fs::read_to_string, path::PathBuf};

use base64::prelude::{Engine, BASE64_STANDARD};
use rustc_hash::FxHashSet;
use sourcemap::SourceMap;
use swc_common::{comments::SingleThreadedComments, source_map::SourceMapGenConfig};
Expand Down Expand Up @@ -489,7 +490,7 @@ fn visualizer_url(code: &str, map: &SourceMap) -> String {

let code_len = format!("{}\0", code.len());
let map_len = format!("{}\0", map.len());
let hash = base64::encode(format!("{}{}{}{}", code_len, code, map_len, map));
let hash = BASE64_STANDARD.encode(format!("{}{}{}{}", code_len, code, map_len, map));

format!("https://evanw.github.io/source-map-visualization/#{}", hash)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_transforms_react/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ default = ["serde-impl"]
serde-impl = ["serde"]

[dependencies]
base64 = "0.13.0"
base64 = "0.21.0"
dashmap = "5.4.0"
indexmap = "1.9.3"
once_cell = "1.18.0"
Expand Down
3 changes: 2 additions & 1 deletion crates/swc_ecma_transforms_react/src/refresh/hook.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{fmt::Write, mem};

use base64::prelude::{Engine, BASE64_STANDARD};
use sha1::{Digest, Sha1};
use swc_common::{util::take::Take, SourceMap, SourceMapper, Spanned, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
Expand Down Expand Up @@ -104,7 +105,7 @@ impl<'a> HookRegister<'a> {
} else {
let mut hasher = Sha1::new();
hasher.update(sign);
base64::encode(hasher.finalize())
BASE64_STANDARD.encode(hasher.finalize())
};

args.push(
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_transforms_testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bench = false
[dependencies]
ansi_term = "0.12.1"
anyhow = "1"
base64 = "0.13"
base64 = "0.21"
hex = "0.4.3"
serde = "1"
serde_json = "1"
Expand Down
3 changes: 2 additions & 1 deletion crates/swc_ecma_transforms_testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::{

use ansi_term::Color;
use anyhow::Error;
use base64::prelude::{Engine, BASE64_STANDARD};
use serde::de::DeserializeOwned;
use sha1::{Digest, Sha1};
use swc_common::{
Expand Down Expand Up @@ -902,7 +903,7 @@ fn visualizer_url(code: &str, map: &sourcemap::SourceMap) -> String {

let code_len = format!("{}\0", code.len());
let map_len = format!("{}\0", map.len());
let hash = base64::encode(format!("{}{}{}{}", code_len, code, map_len, map));
let hash = BASE64_STANDARD.encode(format!("{}{}{}{}", code_len, code, map_len, map));

format!("https://evanw.github.io/source-map-visualization/#{}", hash)
}
Expand Down

0 comments on commit c2d1a6c

Please sign in to comment.