Vite · VITE0021

Use Vite's static worker URL pattern

Checks that Vite worker code includes the worker URL pattern needed for predictable behavior.
VITE0021vite-doctor/viteworkerswarnNo fix
vite/worker/require-worker-url-patternsrc/rule-packs/vite/rules/worker.ts Upstream docs

Run this rule

pnpm vite-doctor . --framework vite --rules vite/worker/require-worker-url-pattern

Why it matters

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

Add worker URL pattern where Vite expects it, close to the code that depends on it.

Example

Use Vite worker URL pattern

Before

const worker = new Worker('./worker.ts')

After

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