Skip to content

Commit

Permalink
fix: import.meta compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
XiSenao committed Dec 12, 2023
1 parent 3e42611 commit ab55667
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/vite/src/node/plugins/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,15 @@ export function webWorkerPostPlugin(): Plugin {
name: 'vite:worker-post',
resolveImportMeta(property, { chunkId, format }) {
// document is undefined in the worker, so we need to avoid it in iife
if (property === 'url' && format === 'iife') {
return 'self.location.href'
if (format === 'iife') {
if (!property) {
return `{
url: self.location.href
}`
}
if (property === 'url') {
return 'self.location.href'
}
}

return null
Expand Down

0 comments on commit ab55667

Please sign in to comment.