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"] ...@@ -96,7 +96,6 @@ default = ["process_pool"]
process_pool = ["turbopack-node/process_pool"] process_pool = ["turbopack-node/process_pool"]
worker_pool = ["turbopack-node/worker_pool"] worker_pool = ["turbopack-node/worker_pool"]
next-font-local = [] next-font-local = []
image-webp = ["turbopack-image/webp"]
image-avif = ["turbopack-image/avif"] image-avif = ["turbopack-image/avif"]
# enable "HMR" for embedded assets # enable "HMR" for embedded assets
......
...@@ -8,12 +8,7 @@ publish = false ...@@ -8,12 +8,7 @@ publish = false
crate-type = ["cdylib"] crate-type = ["cdylib"]
[features] [features]
image-webp = ["next-core/image-webp"]
image-avif = ["next-core/image-avif"] 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. # Enable dhat profiling allocator for heap profiling.
__internal_dhat-heap = ["dhat"] __internal_dhat-heap = ["dhat"]
......
...@@ -38,14 +38,13 @@ See below tables for the currently enabled features. ...@@ -38,14 +38,13 @@ See below tables for the currently enabled features.
| arch\platform | Linux(gnu) | Linux(musl) | Darwin | Windows | | 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 | | x64 | a,b,d,f | a,b,d,f | a,b,d,f | a,b,d,f |
| aarch64 | a,d,e,f | a,d,e,f | a,b,d,e,f | a,b,c,e | | aarch64 | a,d,f | a,d,f | a,b,d,f | a,b,c |
- a: `turbo_tasks_malloc` - a: `turbo_tasks_malloc`
- b: `turbo_tasks_malloc_custom_allocator` - b: `turbo_tasks_malloc_custom_allocator`
- c: `native-tls` (via `turbo-tasks-fetch`) - c: `native-tls` (via `turbo-tasks-fetch`)
- d: `rustls-tls` (via `turbo-tasks-fetch`) - d: `rustls-tls` (via `turbo-tasks-fetch`)
- e: `image-extended` (webp)
- f: `plugin` - f: `plugin`
### Package hierarchies ### Package hierarchies
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
"scripts": { "scripts": {
"build-native-auto": "node maybe-build-native.mjs", "build-native-auto": "node maybe-build-native.mjs",
"clean": "node ../../scripts/rm.mjs native", "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": "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 image-extended,tracing/release_max_level_trace --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 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 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-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", "build-wasm": "wasm-pack build ../../crates/wasm --scope=next",
"cache-build-native": "[ -d native ] && echo $(ls native)", "cache-build-native": "[ -d native ] && echo $(ls native)",
......
...@@ -13,7 +13,6 @@ bench = false ...@@ -13,7 +13,6 @@ bench = false
# [NOTE]: Before enable this, ensure this can build all of the target platforms we support. # [NOTE]: Before enable this, ensure this can build all of the target platforms we support.
avif = ["image/avif"] avif = ["image/avif"]
webp = ["image/webp"]
[lints] [lints]
workspace = true workspace = true
...@@ -30,6 +29,7 @@ image = { workspace = true, default-features = false, features = [ ...@@ -30,6 +29,7 @@ image = { workspace = true, default-features = false, features = [
"ico", "ico",
"bmp", "bmp",
"tga", "tga",
"webp",
] } ] }
mime = { workspace = true } mime = { workspace = true }
phf = { workspace = true } phf = { workspace = true }
...@@ -40,4 +40,3 @@ turbo-rcstr = { workspace = true } ...@@ -40,4 +40,3 @@ turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true } turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true } turbo-tasks-fs = { workspace = true }
turbopack-core = { workspace = true } turbopack-core = { workspace = true }
...@@ -13,6 +13,7 @@ use image::{ ...@@ -13,6 +13,7 @@ use image::{
ico::IcoEncoder, ico::IcoEncoder,
jpeg::JpegEncoder, jpeg::JpegEncoder,
png::{CompressionType, PngEncoder}, png::{CompressionType, PngEncoder},
webp::WebPEncoder,
}, },
imageops::FilterType, imageops::FilterType,
}; };
...@@ -176,23 +177,6 @@ fn load_image_internal( ...@@ -176,23 +177,6 @@ fn load_image_internal(
return Ok((ImageBuffer::Raw(bytes.to_vec()), format)); 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")?; let image = reader.decode().context("unable to decode image data")?;
Ok((ImageBuffer::Decoded(image), format)) Ok((ImageBuffer::Decoded(image), format))
} }
...@@ -264,9 +248,7 @@ fn encode_image(image: DynamicImage, format: ImageFormat, quality: u8) -> Result ...@@ -264,9 +248,7 @@ fn encode_image(image: DynamicImage, format: ImageFormat, quality: u8) -> Result
)?; )?;
(buf, mime::IMAGE_BMP) (buf, mime::IMAGE_BMP)
} }
#[cfg(feature = "webp")]
ImageFormat::WebP => { ImageFormat::WebP => {
use image::codecs::webp::WebPEncoder;
let encoder = WebPEncoder::new_lossless(&mut buf); let encoder = WebPEncoder::new_lossless(&mut buf);
encoder.encode(image.as_bytes(), width, height, image.color().into())?; encoder.encode(image.as_bytes(), width, height, image.color().into())?;
...@@ -443,14 +425,6 @@ pub async fn optimize( ...@@ -443,14 +425,6 @@ pub async fn optimize(
.cell()); .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 { let mime_type = if let Some(format) = format {
image_format_to_mime_type(format)? image_format_to_mime_type(format)?
} else { } 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