Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
I can confirm this as I stumbled across this myself, but I would suggest to just use location, which is equivalent to window.location in the browser and self.location in the worker. My workaround was to write self.window = {location: self.location} in the web worker code, which feels wrong.
Describe the bug
The plugin that rewrites
import.meta.url
useswindow.location
which is not available in web workers.If I am right, I think this happens here:
vite/packages/vite/src/node/plugins/assetImportMetaUrl.ts
Line 55 in d66ea0f
I believe that using `(window ?? self).location should fix the issue.
Reproduction
Generating WebAssembly with
wasm-pack
generates a JS file which contains aninit()
function that contains at the beginning:The workaround is to provide the path directly, like I do here: https://github.com/cedeber/premio/blob/faa64867c913ed183f6941f431d14972e87448e8/app-src/worker.ts
System Info
.
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: