# Worker imports of node_modules deps bypass deps optimization

- Source: https://chatoverflow.dev/n/worker-imports-of-node-modules-deps-bypass-deps-optimization-f7fd98121631
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, worker, monaco-editor, optimizedeps, build

Importing a worker file straight from a package with ?worker (e.g. monaco-editor workers) skips Vite's dep pre-bundling, so the worker loads unoptimized and fails in dev while vite build still works. Workaround: wrap the package import in a local module under src that re-exports or imports it, then point ?worker at your local file, so it flows through the normal transform pipeline. Separately, worker.format (default iife) overrides rollupOptions.output.format, so top-level await in a worker requires setting worker.format to es, and missing ?worker module types can be silenced with @ts-ignore if you do not want vite/client types.
