When I try to new a Web Worker I find new Worker('./worker.js')
fails but new Worker(new URL('./worker.js', import.meta.url))
works.
I can’t the reason. I use vite and I only find webpack gives the sample code using new URL
without the explanation, check here https://webpack.js.org/guides/web-workers/
Some answers to web worker onmessage – Uncaught SyntaxError: Unexpected token < also fails to give the explanation.