Skip to content

Commit

Permalink
fix: avoid errors when loading the overlay code in workers (#9064)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Jul 15, 2022
1 parent 57a7936 commit a52b45e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vite/src/client/overlay.ts
Expand Up @@ -115,6 +115,9 @@ code {
const fileRE = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g
const codeframeRE = /^(?:>?\s+\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm

// Allow `ErrorOverlay` to extend `HTMLElement` even in environments where
// `HTMLElement` was not originally defined.
const { HTMLElement = class {} } = globalThis
export class ErrorOverlay extends HTMLElement {
root: ShadowRoot

Expand Down Expand Up @@ -184,6 +187,7 @@ export class ErrorOverlay extends HTMLElement {
}

export const overlayId = 'vite-error-overlay'
const { customElements } = globalThis // Ensure `customElements` is defined before the next line.
if (customElements && !customElements.get(overlayId)) {
customElements.define(overlayId, ErrorOverlay)
}

0 comments on commit a52b45e

Please sign in to comment.