@lelantos-org/sdk / index / WorkerFactory
Type Alias: WorkerFactory
ts
type WorkerFactory = () => WorkerLike;Defined in: @lelantos-org/sdk/dist/runtime/rpc/types.d.ts:33
Spawns a worker. Callers write the new Worker(...) expression at their own call site: bundlers emit a worker chunk only for that literal form and cannot see a URL passed through a helper (Vite inlines a small worker entry as a data: URL under build.assetsInlineLimit, whose relative imports then fail at runtime). Other bundler forms work too (import W from "…?worker", then () => new W()), and WorkerPoolScanner uses the factory to respawn a dead worker.
ts
() => new Worker(new URL("@lelantos-org/sdk/workers/scanner", import.meta.url), {
type: "module",
})