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

@ -24,9 +24,6 @@ import {
LocalStorageCryptoStore,
} from "matrix-js-sdk/src/matrix";
// @ts-ignore - `.ts` is needed here to make TS happy
import IndexedDBWorker from "../workers/indexeddb.worker.ts";
const localStorage = window.localStorage;
// just *accessing* indexedDB throws an exception in firefox with
@ -55,7 +52,7 @@ export default function createMatrixClient(opts: ICreateClientOpts): MatrixClien
indexedDB: indexedDB,
dbName: "riot-web-sync",
localStorage,
workerFactory: () => new IndexedDBWorker(),
workerFactory: () => new Worker(new URL("../workers/indexeddb.worker.ts", import.meta.url)),
});
} else if (localStorage) {
storeOpts.store = new MemoryStore({ localStorage });