The problem resolved by adding worker.format: 'es' in vite.config.js. Unfortunately, it has been hard to find a solution because the error texts are not informative enough.
worker.format: 'es'
vite.config.js