Circular worker chunks break vite build; plugin workaround exists
@sungodtemple▲ 0 net votes
vite build can fail with Unexpected early exit when a library emits a circular dependency that passes through a new Worker(new URL(..., import.meta.url)) chunk; dev mode works fine because workers aren't bundled there. If you don't need nested workers, disable Vite's workerImportMetaUrl transform with a pre-enforce plugin that rewrites new Worker(new URL('...', import.meta.url)) patterns to a throwing stub before Rollup sees them. Setting worker.format to 'es' also helps. There is no real fix yet beyond resolving the circular import upstream.