Skip to content

Commit f2a2c7b

Browse files
author
a.zavernyaev
committed
Fix windows build and update Cargo.lock
1 parent 0ad5cb0 commit f2a2c7b

8 files changed

Lines changed: 21 additions & 24 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/vite_install/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ reqwest = { workspace = true, features = ["stream", "native-tls-vendored", "json
3838

3939
[target.'cfg(not(target_os = "windows"))'.dependencies]
4040
reqwest = { workspace = true, features = ["stream", "rustls-no-provider", "json"] }
41-
rustls = { workspace = true }
4241

4342
[dev-dependencies]
4443
httpmock = { workspace = true }

crates/vite_install/src/request.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ use tar::Archive;
1111
use tokio::{fs, io::AsyncWriteExt};
1212
use vite_error::Error;
1313

14-
#[cfg(not(target_os = "windows"))]
15-
fn ensure_tls_provider() {
16-
static INIT: std::sync::OnceLock<()> = std::sync::OnceLock::new();
17-
INIT.get_or_init(|| {
18-
let _ = rustls::crypto::ring::default_provider().install_default();
19-
});
20-
}
21-
2214
/// HTTP client with built-in retry support
2315
#[derive(Clone)]
2416
pub struct HttpClient {
@@ -65,7 +57,7 @@ impl HttpClient {
6557
}
6658

6759
async fn get(&self, url: &str) -> Result<Response, Error> {
68-
ensure_tls_provider();
60+
vite_shared::ensure_tls_provider();
6961

7062
let response = (|| async { reqwest::get(url).await?.error_for_status() })
7163
.retry(

crates/vite_js_runtime/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ reqwest = { workspace = true, features = ["stream", "native-tls-vendored"] }
3333

3434
[target.'cfg(not(target_os = "windows"))'.dependencies]
3535
reqwest = { workspace = true, features = ["stream", "rustls-no-provider"] }
36-
rustls = { workspace = true }
3736

3837
[dev-dependencies]
3938
tempfile = { workspace = true }

crates/vite_js_runtime/src/download.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ use vite_str::Str;
1515

1616
use crate::{Error, provider::ArchiveFormat};
1717

18-
#[cfg(not(target_os = "windows"))]
19-
fn ensure_tls_provider() {
20-
static INIT: std::sync::OnceLock<()> = std::sync::OnceLock::new();
21-
INIT.get_or_init(|| {
22-
let _ = rustls::crypto::ring::default_provider().install_default();
23-
});
24-
}
25-
2618
/// Response from a cached fetch operation
2719
pub struct CachedFetchResponse {
2820
/// Response body (None if 304 Not Modified)
@@ -45,7 +37,7 @@ pub async fn download_file(
4537
target_path: &AbsolutePath,
4638
message: &str,
4739
) -> Result<(), Error> {
48-
ensure_tls_provider();
40+
vite_shared::ensure_tls_provider();
4941

5042
tracing::debug!("Downloading {url} to {target_path:?}");
5143

@@ -124,7 +116,7 @@ pub async fn download_file(
124116
/// Download text content from a URL with retry logic
125117
#[expect(clippy::disallowed_types, reason = "HTTP response body is a String")]
126118
pub async fn download_text(url: &str) -> Result<String, Error> {
127-
ensure_tls_provider();
119+
vite_shared::ensure_tls_provider();
128120

129121
tracing::debug!("Downloading text from {url}");
130122

@@ -149,7 +141,7 @@ pub async fn fetch_with_cache_headers(
149141
url: &str,
150142
if_none_match: Option<&str>,
151143
) -> Result<CachedFetchResponse, Error> {
152-
ensure_tls_provider();
144+
vite_shared::ensure_tls_provider();
153145

154146
tracing::debug!("Fetching with cache headers from {url}");
155147

crates/vite_shared/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@ tracing-subscriber = { workspace = true }
1818
vite_path = { workspace = true }
1919
vite_str = { workspace = true }
2020

21+
[target.'cfg(not(target_os = "windows"))'.dependencies]
22+
rustls = { workspace = true }
23+
2124
[lints]
2225
workspace = true

crates/vite_shared/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub mod output;
88
mod package_json;
99
mod path_env;
1010
pub mod string_similarity;
11+
mod tls;
1112
mod tracing;
1213

1314
pub use env_config::{EnvConfig, TestEnvGuard};
@@ -17,4 +18,5 @@ pub use path_env::{
1718
PrependOptions, PrependResult, format_path_prepended, format_path_with_prepend,
1819
prepend_to_path_env,
1920
};
21+
pub use tls::ensure_tls_provider;
2022
pub use tracing::init_tracing;

crates/vite_shared/src/tls.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// Ensure a TLS crypto provider is installed (no-op on Windows which uses native-tls).
2+
#[cfg(not(target_os = "windows"))]
3+
pub fn ensure_tls_provider() {
4+
static INIT: std::sync::OnceLock<()> = std::sync::OnceLock::new();
5+
INIT.get_or_init(|| {
6+
let _ = rustls::crypto::ring::default_provider().install_default();
7+
});
8+
}
9+
10+
#[cfg(target_os = "windows")]
11+
pub fn ensure_tls_provider() {}

0 commit comments

Comments
 (0)