Skip to content

Conversation

@moonclavedev
Copy link
Contributor

Updates the Vercel build image service to correctly handle ESM-imported SVG images by returning the original source path, preventing incorrect URL generation. Also aligns the isESMImportedImage utility with the core Astro implementation.

Fixes #13664

Changes

  • Updated isESMImportedImage in packages/integrations/vercel/src/image/shared.ts to align with the core Astro implementation, correctly identifying SVGs imported as functions.
  • Modified getURL in packages/integrations/vercel/src/image/build-service.ts to return the original src path for SVG images, bypassing the Vercel image processing endpoint for them.

Testing

This change was tested manually by reproducing the scenario described in issue #13664:

  1. Created an Astro project using the Vercel adapter with imageService: true.
  2. Included an SVG image in a markdown file using standard markdown syntax (![Alt text](../path/to/image.svg)).
  3. Observed that before the change, the generated <img> tag had a corrupted src attribute pointing to /_vercel/image?url=(stringified function)....
  4. Applied the changes in this PR.
  5. Observed that after the change, the generated <img> tag correctly points directly to the processed SVG file path (e.g., /_astro/image.hash.svg).

No automated tests were added as this addresses a specific interaction between markdown processing, ESM image imports, and the Vercel build service logic. Existing integration tests for Vercel image handling should continue to pass.

Docs

No documentation changes are needed. This fix addresses an internal bug in the Vercel integration's image service logic and does not change any user-facing APIs or behavior (other than correcting the bug).

Updates the Vercel build image service to correctly handle
ESM-imported SVG images by returning the original source path,
preventing incorrect URL generation. Also aligns the
isESMImportedImage utility with the core Astro implementation.

Fixes withastro#13664
@changeset-bot
Copy link

changeset-bot bot commented Apr 24, 2025

🦋 Changeset detected

Latest commit: 1ed1e44

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Apr 24, 2025
Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Could you add a test for this. There are existing image tests in the vercel package where it could be added.

Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we help you?

};
}

export function isESMImportedImage(src: ImageMetadata | string): src is ImageMetadata {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed in favor of isESMImportedImage exported from astro/assets/utils

@florian-lefebvre florian-lefebvre merged commit 4a8f193 into withastro:main Jun 3, 2025
14 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Jun 3, 2025
openscript pushed a commit to openscript/astro that referenced this pull request Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vercel Adapter + imageService / imagesConfig breaking .SVG since Astro 5.7

3 participants