Skip to content

Commit 386de4d

Browse files
authored
put webp behind a feature flag (vercel/turborepo#4641)
### Description aarch64 is unable to compile it, so we disable it for now
1 parent dfcca5c commit 386de4d

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

crates/turbo-binding/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ __turbopack_dev_server = ["__turbopack", "turbopack-dev-server"]
110110
__turbopack_ecmascript = ["__turbopack", "turbopack-ecmascript"]
111111
__turbopack_env = ["__turbopack", "turbopack-env"]
112112
__turbopack_image = ["__turbopack", "turbopack-image"]
113+
__turbopack_image_avif = ["turbopack-image/avif"]
114+
__turbopack_image_webp = ["turbopack-image/webp"]
113115
__turbopack_json = ["__turbopack", "turbopack-json"]
114116
__turbopack_mdx = ["__turbopack", "turbopack-mdx"]
115117
__turbopack_node = ["__turbopack", "turbopack-node"]

crates/turbopack-image/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ bench = false
1111

1212
[features]
1313
avif = ["image/avif-decoder", "image/avif-encoder"]
14+
webp = ["image/webp", "image/webp-encoder"]
1415

1516
[dependencies]
1617
anyhow = { workspace = true }
1718
base64 = "0.21.0"
1819
image = { workspace = true, default-features = false, features = [
19-
"webp",
2020
"png",
2121
"jpeg",
22-
"webp-encoder",
22+
"ico",
23+
"bmp",
24+
"tga",
2325
] }
2426
indexmap = { workspace = true }
2527
mime = { workspace = true }

crates/turbopack-image/src/process.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use image::{
66
codecs::{
77
jpeg::JpegEncoder,
88
png::{CompressionType, PngEncoder},
9-
webp::{WebPEncoder, WebPQuality},
109
},
1110
imageops::FilterType,
1211
GenericImageView, ImageEncoder, ImageFormat,
@@ -100,7 +99,9 @@ fn compute_blur_data(
10099
Base64Display::new(&buf, &STANDARD)
101100
)
102101
}
102+
#[cfg(feature = "webp")]
103103
ImageFormat::WebP => {
104+
use image::webp::{WebPEncoder, WebPQuality};
104105
WebPEncoder::new_with_quality(&mut buf, WebPQuality::lossy(options.quality))
105106
.write_image(
106107
small_image.as_bytes(),
@@ -127,7 +128,10 @@ fn compute_blur_data(
127128
Base64Display::new(&buf, &STANDARD)
128129
)
129130
}
130-
_ => unreachable!(),
131+
_ => bail!(
132+
"Ecoding for image format {:?} has not been compiled into the current build",
133+
format
134+
),
131135
};
132136

133137
Ok((url, blur_width, blur_height))

0 commit comments

Comments
 (0)