Skip to content

Commit a00f6f6

Browse files
committed
fix: import.meta compilation error
1 parent 3e42611 commit a00f6f6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/vite/src/node/plugins/worker.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,19 @@ export async function workerFileToUrl(
165165
export function webWorkerPostPlugin(): Plugin {
166166
return {
167167
name: 'vite:worker-post',
168-
resolveImportMeta(property, { chunkId, format }) {
168+
resolveImportMeta(property, { format }) {
169169
// document is undefined in the worker, so we need to avoid it in iife
170-
if (property === 'url' && format === 'iife') {
171-
return 'self.location.href'
170+
if (format === 'iife') {
171+
// compiling import.meta
172+
if (!property) {
173+
return `{
174+
url: self.location.href
175+
}`
176+
}
177+
// compiling import.meta.url
178+
if (property === 'url') {
179+
return 'self.location.href'
180+
}
172181
}
173182

174183
return null

0 commit comments

Comments
 (0)