Skip to content
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

Add ".catch()" here to handle failure at run-time #4266

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/integrations/image/src/lib/get-image.ts
Expand Up @@ -107,7 +107,9 @@ export async function getImage(

if (!loader) {
// @ts-ignore
const { default: mod } = await import('virtual:image-loader');
const { default: mod } = await import('virtual:image-loader').catch((error) => {
Copy link
Member

Choose a reason for hiding this comment

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

this will actually still fail, since it would return undefined and you can't do const {default: mod} = undefined.

Created a new PR to solve this along with another error here: #4279

Thanks for helping to point the way to this part of the code!

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your feedback, I saw that you were able to include this part in your PR, glad if I could help you 🙂

console.error(error);
});
loader = mod as ImageService;
globalThis.astroImage = globalThis.astroImage || {};
globalThis.astroImage.loader = loader;
Expand Down