Vite · Workers

VITE0019Keep Vite worker URLs static

Flags dynamic worker URL in Vite worker code before it leaks into runtime behavior.

Why it happens

Vite configuration runs in both dev and build pipelines. Narrow, explicit settings reduce surprises across SSR, workers, and local file access.

Fix

Remove dynamic worker URL, or move it to the Vite runtime/API that owns that behavior.

Example

Use static worker URLs

Before

const worker = new Worker(new URL(`./workers/${name}.ts`, import.meta.url))

After

const worker = new Worker(new URL('./workers/sync.ts', import.meta.url), { type: 'module' })

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework vite --rules vite/worker/no-dynamic-worker-url
Copyright © 2026