-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(vercel): handle SVG images correctly in build image service #13679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(vercel): handle SVG images correctly in build image service #13679
Conversation
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 detectedLatest 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 |
There was a problem hiding this 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.
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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
…astro#13679) Co-authored-by: Matt Kane <[email protected]> Co-authored-by: Florian Lefebvre <[email protected]>
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
isESMImportedImageinpackages/integrations/vercel/src/image/shared.tsto align with the core Astro implementation, correctly identifying SVGs imported as functions.getURLinpackages/integrations/vercel/src/image/build-service.tsto return the originalsrcpath 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:
imageService: true.).<img>tag had a corruptedsrcattribute pointing to/_vercel/image?url=(stringified function)....<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).