From e1fced4260c02f3e4e1c381603ae54f2b57a6198 Mon Sep 17 00:00:00 2001 From: Princesseuh <3019731+Princesseuh@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:24:58 +0200 Subject: [PATCH] chore: changeset --- .changeset/fair-rats-fail.md | 5 +++++ packages/astro/config.d.ts | 3 +++ packages/astro/src/assets/services/squoosh.ts | 10 ++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .changeset/fair-rats-fail.md diff --git a/.changeset/fair-rats-fail.md b/.changeset/fair-rats-fail.md new file mode 100644 index 000000000000..b93bc8a2b5aa --- /dev/null +++ b/.changeset/fair-rats-fail.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Deprecates the Squoosh image service, to be removed in Astro 5.0. We recommend migrating to the default Sharp service. diff --git a/packages/astro/config.d.ts b/packages/astro/config.d.ts index 9f4c6bfd112d..68743b35d37a 100644 --- a/packages/astro/config.d.ts +++ b/packages/astro/config.d.ts @@ -26,6 +26,9 @@ export function getViteConfig( export function sharpImageService(config?: SharpImageServiceConfig): ImageServiceConfig; /** + * @deprecated The Squoosh image service is deprecated and will be removed in Astro 5.x. + * We suggest migrating to the default Sharp image service instead, as it is faster, more powerful and better maintained. + * * Return the configuration needed to use the Squoosh-based image service * See: https://docs.astro.build/en/guides/images/#configure-squoosh */ diff --git a/packages/astro/src/assets/services/squoosh.ts b/packages/astro/src/assets/services/squoosh.ts index 6eb78db4b2ee..b98f831d27a9 100644 --- a/packages/astro/src/assets/services/squoosh.ts +++ b/packages/astro/src/assets/services/squoosh.ts @@ -1,5 +1,4 @@ -// TODO: Investigate removing this service once sharp lands WASM support, as libsquoosh is deprecated - +import { yellow } from 'kleur/colors'; import type { ImageOutputFormat, ImageQualityPreset } from '../types.js'; import { imageMetadata } from '../utils/metadata.js'; import { @@ -11,6 +10,13 @@ import { import { processBuffer } from './vendor/squoosh/image-pool.js'; import type { Operation } from './vendor/squoosh/image.js'; +// eslint-disable-next-line no-console +console.warn( + yellow( + 'The Squoosh image service is deprecated and will be removed in Astro 5.x. We suggest migrating to the default Sharp image service instead, as it is faster, more powerful and better maintained.', + ), +); + const baseQuality = { low: 25, mid: 50, high: 80, max: 100 }; const qualityTable: Record< Exclude,