diff --git a/examples/vite-core/vite.config.ts b/examples/vite-core/vite.config.ts index 9d32eae..a03934d 100644 --- a/examples/vite-core/vite.config.ts +++ b/examples/vite-core/vite.config.ts @@ -16,5 +16,6 @@ export default defineConfig({ build: { target: 'esnext', sourcemap: true, + minify: false, }, }) diff --git a/packages/core-web/src/FedimintWallet.ts b/packages/core-web/src/FedimintWallet.ts index d2b8280..c28d943 100644 --- a/packages/core-web/src/FedimintWallet.ts +++ b/packages/core-web/src/FedimintWallet.ts @@ -56,7 +56,7 @@ export class FedimintWallet { this.openPromise = new Promise((resolve) => { this.resolveOpen = resolve }) - this.client = new WorkerClient(new URL('worker.js', import.meta.url)) + this.client = new WorkerClient() this.mint = new MintService(this.client) this.lightning = new LightningService(this.client) this.balance = new BalanceService(this.client) diff --git a/packages/core-web/src/transport/WorkerClient.ts b/packages/core-web/src/transport/WorkerClient.ts index ef5d561..e340df5 100644 --- a/packages/core-web/src/transport/WorkerClient.ts +++ b/packages/core-web/src/transport/WorkerClient.ts @@ -14,8 +14,11 @@ export class WorkerClient { private requestCallbacks = new Map void>() private initPromise: Promise | null = null - constructor(workerUrl: URL) { - this.worker = new Worker(workerUrl, { type: 'module' }) + constructor() { + // Must create the URL inside the constructor for vite + this.worker = new Worker(new URL('./worker.js', import.meta.url), { + type: 'module', + }) this.worker.onmessage = this.handleWorkerMessage.bind(this) this.worker.onerror = this.handleWorkerError.bind(this) }