Load web workers in a way that Webpack 5 can bundle them

This commit is contained in:
Johannes Marbach 2023-11-11 16:03:08 +01:00
parent cfd5165cd8
commit 84d7d43a0d
5 changed files with 13 additions and 12 deletions

View file

@ -23,8 +23,8 @@ export class WorkerManager<Request extends {}, Response> {
private seq = 0;
private pendingDeferredMap = new Map<number, IDeferred<Response>>();
public constructor(WorkerConstructor: { new (): Worker }) {
this.worker = new WorkerConstructor();
public constructor(worker: Worker) {
this.worker = worker;
this.worker.onmessage = this.onMessage;
}