Skip to content

Commit

Permalink
Deprecate the Squoosh image service (#11780)
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh authored Aug 20, 2024
1 parent 1fd84b6 commit c6622ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-rats-fail.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions packages/astro/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
10 changes: 8 additions & 2 deletions packages/astro/src/assets/services/squoosh.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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<ImageOutputFormat, 'png' | 'svg'>,
Expand Down

0 comments on commit c6622ad

Please sign in to comment.