Skip to content

Commit

Permalink
fix: guard asset global usage (#11171)
Browse files Browse the repository at this point in the history
* fix: guard global usage

* chore: changeset
  • Loading branch information
Princesseuh authored May 31, 2024
1 parent 464b0a1 commit ff8004f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gentle-moose-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Guard globalThis.astroAsset usage in proxy code to avoid errors in wonky situations
2 changes: 1 addition & 1 deletion packages/astro/src/assets/utils/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function getProxyCode(options: ImageMetadata, isSSR: boolean): string {
}
${
!isSSR
? `if (target[name] !== undefined) globalThis.astroAsset.referencedImages.add(${stringifiedFSPath});`
? `if (target[name] !== undefined && globalThis.astroAsset) globalThis.astroAsset?.referencedImages.add(${stringifiedFSPath});`
: ''
}
return target[name];
Expand Down

0 comments on commit ff8004f

Please sign in to comment.