Unverified Commit 5b370524 authored by Benjamin Woodruff ‮'s avatar Benjamin Woodruff Committed by GitHub

Turbopack: Remove webp feature flag, always build with webp enabled (#99964)

Since image-rs 0.25, they use a Rust implementation of webp, so there's
no platform compatibility concerns with webp anymore.

We were already enabling it everywhere (except for wasm, which seems
like an oversight).

Get rid of the feature flag and enable it unconditionally.
parent bdcfe429
......@@ -96,7 +96,6 @@ default = ["process_pool"]
process_pool = ["turbopack-node/process_pool"]
worker_pool = ["turbopack-node/worker_pool"]
next-font-local = []
image-webp = ["turbopack-image/webp"]
image-avif = ["turbopack-image/avif"]
# enable "HMR" for embedded assets
......
......@@ -8,12 +8,7 @@ publish = false
crate-type = ["cdylib"]
[features]
image-webp = ["next-core/image-webp"]
image-avif = ["next-core/image-avif"]
# Enable all the available image codec support.
# Currently this is identical to `image-webp`, as we are not able to build
# other codecs easily yet.
image-extended = ["image-webp"]
# Enable dhat profiling allocator for heap profiling.
__internal_dhat-heap = ["dhat"]
......
......@@ -38,14 +38,13 @@ See below tables for the currently enabled features.
| arch\platform | Linux(gnu) | Linux(musl) | Darwin | Windows |
| ------------- | ---------- | ----------- | --------- | --------- |
| x64 | a,b,d,e,f | a,b,d,e,f | a,b,d,e,f | a,b,d,e,f |
| aarch64 | a,d,e,f | a,d,e,f | a,b,d,e,f | a,b,c,e |
| x64 | a,b,d,f | a,b,d,f | a,b,d,f | a,b,d,f |
| aarch64 | a,d,f | a,d,f | a,b,d,f | a,b,c |
- a: `turbo_tasks_malloc`
- b: `turbo_tasks_malloc_custom_allocator`
- c: `native-tls` (via `turbo-tasks-fetch`)
- d: `rustls-tls` (via `turbo-tasks-fetch`)
- e: `image-extended` (webp)
- f: `plugin`
### Package hierarchies
......
......@@ -8,9 +8,9 @@
"scripts": {
"build-native-auto": "node maybe-build-native.mjs",
"clean": "node ../../scripts/rm.mjs native",
"build-native": "napi build --platform -p next-napi-bindings --manifest-path ../../Cargo.toml --features image-extended --no-js -o native",
"build-native-release": "napi build --platform -p next-napi-bindings --manifest-path ../../Cargo.toml --release --features image-extended,tracing/release_max_level_trace --no-js -o native",
"build-native-release-with-assertions": "napi build --platform -p next-napi-bindings --manifest-path ../../Cargo.toml --profile release-with-assertions --features image-extended,tracing/release_max_level_trace --no-js -o native",
"build-native": "napi build --platform -p next-napi-bindings --manifest-path ../../Cargo.toml --no-js -o native",
"build-native-release": "napi build --platform -p next-napi-bindings --manifest-path ../../Cargo.toml --release --features tracing/release_max_level_trace --no-js -o native",
"build-native-release-with-assertions": "napi build --platform -p next-napi-bindings --manifest-path ../../Cargo.toml --profile release-with-assertions --features tracing/release_max_level_trace --no-js -o native",
"build-native-wasi": "napi build --platform --target wasm32-wasip1-threads -p next-napi-bindings --manifest-path ../../Cargo.toml --no-default-features -o native",
"build-wasm": "wasm-pack build ../../crates/wasm --scope=next",
"cache-build-native": "[ -d native ] && echo $(ls native)",
......
......@@ -13,7 +13,6 @@ bench = false
# [NOTE]: Before enable this, ensure this can build all of the target platforms we support.
avif = ["image/avif"]
webp = ["image/webp"]
[lints]
workspace = true
......@@ -30,6 +29,7 @@ image = { workspace = true, default-features = false, features = [
"ico",
"bmp",
"tga",
"webp",
] }
mime = { workspace = true }
phf = { workspace = true }
......@@ -40,4 +40,3 @@ turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true }
turbopack-core = { workspace = true }
......@@ -13,6 +13,7 @@ use image::{
ico::IcoEncoder,
jpeg::JpegEncoder,
png::{CompressionType, PngEncoder},
webp::WebPEncoder,
},
imageops::FilterType,
};
......@@ -176,23 +177,6 @@ fn load_image_internal(
return Ok((ImageBuffer::Raw(bytes.to_vec()), format));
}
#[cfg(not(feature = "webp"))]
if matches!(format, Some(ImageFormat::WebP)) {
ImageProcessingIssue {
source: IssueSource::from_source_only(image),
message: StyledString::Text(rcstr!(
"This version of Turbopack does not support WEBP images, will emit without \
optimization or encoding"
))
.resolved_cell(),
title: Some(StyledString::Text(rcstr!("WEBP image not supported")).resolved_cell()),
issue_severity: Some(IssueSeverity::Warning),
}
.resolved_cell()
.emit();
return Ok((ImageBuffer::Raw(bytes.to_vec()), format));
}
let image = reader.decode().context("unable to decode image data")?;
Ok((ImageBuffer::Decoded(image), format))
}
......@@ -264,9 +248,7 @@ fn encode_image(image: DynamicImage, format: ImageFormat, quality: u8) -> Result
)?;
(buf, mime::IMAGE_BMP)
}
#[cfg(feature = "webp")]
ImageFormat::WebP => {
use image::codecs::webp::WebPEncoder;
let encoder = WebPEncoder::new_lossless(&mut buf);
encoder.encode(image.as_bytes(), width, height, image.color().into())?;
......@@ -443,14 +425,6 @@ pub async fn optimize(
.cell());
}
#[cfg(not(feature = "webp"))]
if matches!(format, Some(ImageFormat::WebP)) {
return Ok(FileContent::Content(
File::from(buffer).with_content_type(Mime::from_str("image/webp")?),
)
.cell());
}
let mime_type = if let Some(format) = format {
image_format_to_mime_type(format)?
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment