diff --git a/src/platform/web/sync/SyncProxy.ts b/src/platform/web/sync/SyncProxy.ts index 8d96ce5d4e..bd5d422983 100644 --- a/src/platform/web/sync/SyncProxy.ts +++ b/src/platform/web/sync/SyncProxy.ts @@ -27,7 +27,9 @@ export class SyncProxy implements ISync { } async start(): Promise { - this._worker = new SharedWorker(new URL("./sync-worker", import.meta.url)); + this._worker = new SharedWorker(new URL("./sync-worker", import.meta.url), { + type: "module", + }); this._worker.port.onmessage = (event: MessageEvent) => { // TODO console.log(event); diff --git a/src/platform/web/sync/sync-worker.js b/src/platform/web/sync/sync-worker.js deleted file mode 100644 index c70e4e233b..0000000000 --- a/src/platform/web/sync/sync-worker.js +++ /dev/null @@ -1,7 +0,0 @@ -// TODO - -self.onconnect = (event) => { - const port = event.ports[0]; - port.postMessage("hello from sync worker"); - console.log("hello from sync worker"); -} diff --git a/src/platform/web/sync/sync-worker.ts b/src/platform/web/sync/sync-worker.ts new file mode 100644 index 0000000000..be7a1f6751 --- /dev/null +++ b/src/platform/web/sync/sync-worker.ts @@ -0,0 +1,12 @@ +/// + +// The empty export makes this a module. It can be removed once there's at least one import. +export {} + +declare let self: SharedWorkerGlobalScope; + +self.onconnect = (event: MessageEvent) => { + const port = event.ports[0]; + port.postMessage("hello from sync worker"); + console.log("hello from sync worker"); +}