diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 41552d4979312..f3f072bfa4fba 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -102,6 +102,29 @@ import { ClientRouter } from 'astro:transitions'; Read more about [view transitions and client-side routing in Astro](/en/guides/view-transitions/). +### Removed: `emitESMImage()` + + + +In Astro 5.6.2, the `emitESMImage()` function was deprecated in favor of `emitImageMetadata()`, which removes two deprecated arguments that were not meant to be exposed for public use: `_watchMode` and `experimentalSvgEnabled`. + +Astro 6.0 removes `emitESMImage()` entirely. Update to `emitImageMetadata()` to keep your current behavior. + +#### What should I do? + +Replace all occurrences of the `emitESMImage()` with `emitImageMetadata()` and remove unused arguments: + +```ts del={1,5} ins={2,6} +import { emitESMImage } from 'astro/assets/utils'; +import { emitImageMetadata } from 'astro/assets/utils'; + +const imageId = '/images/photo.jpg'; +const result = await emitESMImage(imageId, false, false); +const result = await emitImageMetadata(imageId); +``` + +Read more about [`emitImageMetadata()`](/en/reference/image-service-reference/#emitimagemetadata). + ## Changed Defaults Some default behavior has changed in Astro v5.0 and your project code may need updating to account for these changes. diff --git a/src/content/docs/en/reference/image-service-reference.mdx b/src/content/docs/en/reference/image-service-reference.mdx index c77da89618558..ce7a20c8b335d 100644 --- a/src/content/docs/en/reference/image-service-reference.mdx +++ b/src/content/docs/en/reference/image-service-reference.mdx @@ -601,48 +601,6 @@ async function extractImageMetadata() { await extractImageMetadata(); ``` -### `emitESMImage()` - -:::caution[Deprecated] -Use the [`emitImageMetadata`](#emitimagemetadata) function instead. -::: - -

- **Type:** `(id: string | undefined, _watchMode: boolean, experimentalSvgEnabled: boolean, fileEmitter?: FileEmitter) => Promise`
- -

- - -Processes an image file and emits its metadata and optionally its contents. In build mode, the function uses `fileEmitter` to generate an asset reference. In development mode, it resolves to a local file URL with query parameters for metadata. - -```ts - -import { emitESMImage } from 'astro/assets/utils'; - -const imageId = '/images/photo.jpg'; -const unusedWatchMode = false; // Deprecated, unused -const unusedExperimentalSvgEnabled = false; // Set to `true` only if you are using SVG and want the file data to be embedded - -try { - const result = await emitESMImage(imageId, unusedWatchMode, unusedExperimentalSvgEnabled); - if (result) { - console.log('Image metadata with contents:', result); - // Example output: - // { - // width: 800, - // height: 600, - // format: 'jpg', - // contents: Uint8Array([...]) - // } - } else { - console.log('No metadata was emitted for this image.'); - } -} catch (error) { - console.error('Failed to emit ESM image:', error); -} - -``` - ### `emitImageMetadata()`