Skip to content

Commit

Permalink
feat(turbopack): support native webp (#52285)
Browse files Browse the repository at this point in the history
### What?

Closes WEB-1157. PR enables turbopack to support native webp encode / decode. There is one platform we can't support this (aarch64-linux-gnu) which disables those.
  • Loading branch information
kwonoj committed Jul 12, 2023
1 parent bb0fecc commit e1baffc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_deploy.yml
Expand Up @@ -143,7 +143,7 @@ jobs:
rustup target add aarch64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi &&
export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc &&
turbo run build-native-release --remote-cache-timeout 90 --summarize -- --target aarch64-unknown-linux-gnu &&
turbo run build-native-release --remote-cache-timeout 90 --summarize -- --target aarch64-unknown-linux-gnu --features plugin,rustls-tls,tracing/release_max_level_info &&
llvm-strip -x packages/next-swc/native/next-swc.*.node
- host: ubuntu-latest
target: 'aarch64-unknown-linux-musl'
Expand Down
1 change: 1 addition & 0 deletions packages/next-swc/crates/napi/Cargo.toml
Expand Up @@ -20,6 +20,7 @@ sentry_rustls = ["sentry", "sentry/rustls", "rustls-tls"]
native-tls = ["next-dev/native-tls"]
rustls-tls = ["next-dev/rustls-tls"]
serializable = ["next-dev/serializable"]
image-webp = ["next-core/image-webp"]

# Enable dhat profiling allocator for heap profiling.
__internal_dhat-heap = ["dhat"]
Expand Down
2 changes: 2 additions & 0 deletions packages/next-swc/crates/next-core/Cargo.toml
Expand Up @@ -68,6 +68,8 @@ next-font-local = []
native-tls = ["turbopack-binding/__turbo_tasks_fetch_native-tls"]
rustls-tls = ["turbopack-binding/__turbo_tasks_fetch_rustls-tls"]
plugin = ["turbopack-binding/__swc_core_binding_napi_plugin"]
image-webp = ["turbopack-binding/__turbopack_image_webp"]

# enable "HMR" for embedded assets
dynamic_embed_contents = [
"turbopack-binding/__turbo_tasks_fs_dynamic_embed_contents",
Expand Down
10 changes: 5 additions & 5 deletions packages/next-swc/package.json
Expand Up @@ -4,11 +4,11 @@
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
"build-native": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --features plugin,rustls-tls --js false native",
"build-native-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --features plugin,rustls-tls,tracing/release_max_level_info --js false native",
"build-native-no-plugin": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --js false native",
"build-native-no-plugin-woa": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --cargo-flags=--no-default-features --features native-tls --js false native",
"build-native-no-plugin-woa-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --cargo-flags=--no-default-features --features native-tls,tracing/release_max_level_info --js false native",
"build-native": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --features plugin,rustls-tls,image-webp --js false native",
"build-native-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --features plugin,rustls-tls,image-webp,tracing/release_max_level_info --js false native",
"build-native-no-plugin": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --features image-webp --js false native",
"build-native-no-plugin-woa": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --cargo-flags=--no-default-features --features native-tls,image-webp --js false native",
"build-native-no-plugin-woa-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --cargo-flags=--no-default-features --features native-tls,image-webp,tracing/release_max_level_info --js false native",
"build-wasm": "wasm-pack build crates/wasm --scope=next",
"cache-build-native": "echo $(ls native)",
"rust-check": "cd ../../; cargo fmt -- --check && cargo clippy --all -- -D warnings -A deprecated && cargo check -p next-dev --no-default-features --features cli,custom_allocator,rustls-tls,serializable && rm -rf target",
Expand Down

0 comments on commit e1baffc

Please sign in to comment.