Skip to content

Commit 2f951cd

Browse files
Princesseuhematipico
authored andcommitted
feat: make Sharp the default image service (#7908)
* feat: make Sharp the default image service * chore: lockfile
1 parent fb5cd6b commit 2f951cd

4 files changed

Lines changed: 22 additions & 12 deletions

File tree

.changeset/four-houses-compete.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'astro': major
3+
---
4+
5+
Sharp is now the default image service used for `astro:assets`. If you would prefer to still use Squoosh, you can update your config with the following:
6+
7+
```ts
8+
import { defineConfig, squooshImageService } from "astro/config";
9+
10+
// https://astro.build/config
11+
export default defineConfig({
12+
image: {
13+
service: squooshImageService(),
14+
}
15+
})
16+
```
17+
18+
However, not only do we recommend using Sharp as it is faster and more reliable, it is also highly likely that the Squoosh service will be removed in a future release.

packages/astro/package.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
"mime": "^3.0.0",
154154
"network-information-types": "^0.1.1",
155155
"ora": "^6.3.1",
156+
"sharp": "^0.32.1",
156157
"p-limit": "^4.0.0",
157158
"path-to-regexp": "^6.2.1",
158159
"preferred-pm": "^3.0.3",
@@ -209,19 +210,10 @@
209210
"remark-code-titles": "^0.1.2",
210211
"rollup": "^3.25.1",
211212
"sass": "^1.63.4",
212-
"sharp": "^0.32.1",
213213
"srcset-parse": "^1.1.0",
214214
"undici": "^5.22.1",
215215
"unified": "^10.1.2"
216216
},
217-
"peerDependencies": {
218-
"sharp": ">=0.31.0"
219-
},
220-
"peerDependenciesMeta": {
221-
"sharp": {
222-
"optional": true
223-
}
224-
},
225217
"engines": {
226218
"node": ">=18.14.1",
227219
"npm": ">=6.14.0"

packages/astro/src/@types/astro.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import type { AstroConfigSchema } from '../core/config';
2020
import type { AstroTimer } from '../core/config/timer';
2121
import type { AstroCookies } from '../core/cookies';
2222
import type { LogOptions, LoggerLevel } from '../core/logger/core';
23+
import { AstroIntegrationLogger } from '../core/logger/core';
2324
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
2425
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
25-
import { AstroIntegrationLogger } from '../core/logger/core';
2626
export type {
2727
MarkdownHeading,
2828
MarkdownMetadata,
@@ -987,7 +987,7 @@ export interface AstroUserConfig {
987987
* @docs
988988
* @name image.service (Experimental)
989989
* @type {{entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | string, config: Record<string, any>}}
990-
* @default `{entrypoint: 'astro/assets/services/squoosh', config?: {}}`
990+
* @default `{entrypoint: 'astro/assets/services/sharp', config?: {}}`
991991
* @version 2.1.0
992992
* @description
993993
* Set which image service is used for Astro’s experimental assets support.

packages/astro/src/core/config/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export const AstroConfigSchema = z.object({
191191
}),
192192
})
193193
.default({
194-
service: { entrypoint: 'astro/assets/services/squoosh', config: {} },
194+
service: { entrypoint: 'astro/assets/services/sharp', config: {} },
195195
}),
196196
markdown: z
197197
.object({

0 commit comments

Comments
 (0)