Build fails on self reference worker new Worker(new URL(..., import.meta.url))
in dependency
#17843
Closed
7 tasks done
Labels
Describe the bug
related: #16103
I wasn't sure if this case is intended to work or not, but since the same code works inside the user code (as seen in the test cases added in #16103), I thought it's worth raising an issue to confirm.
I noticed this when adding a test case #17837, but the similar pattern is used in https://github.com/gkjohnson/three-mesh-bvh (which is the dependency of https://github.com/gkjohnson/three-gpu-pathtracer) and I confirmed the build is failing in their examples hi-ogawa/three-gpu-pathtracer#1. Self reference happens here https://github.com/gkjohnson/three-mesh-bvh/blob/9718501eee2619f1015fa332d7bddafaf6cf562a/src/workers/parallelMeshBVH.worker.js#L12
Workaround might be to use
new Worker(self.location.self)
and it seems to work on my reproduction, but not sure if package authors would adopt this in general (also not sure if this is fool proof).Reproduction
https://github.com/hi-ogawa/reproductions/tree/main/vite-16103-new-url-worker-self-reference-build
Steps to reproduce
pnpm build
System Info
(stackblitz) System: OS: Linux 5.0 undefined CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 18.20.3 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 10.2.3 - /usr/local/bin/npm pnpm: 8.15.6 - /usr/local/bin/pnpm npmPackages: vite: ^5.4.0 => 5.4.0
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: