From 6b9c54a74a865d4e83256ee213a3619a537d8612 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 23 Nov 2024 01:47:53 -0800 Subject: [PATCH] No way to import in worker besides as modules, so start figuring out workarounds. --- src/lib/workers/ckdBlake2b.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/workers/ckdBlake2b.ts b/src/lib/workers/ckdBlake2b.ts index 166d7ab..a966240 100644 --- a/src/lib/workers/ckdBlake2b.ts +++ b/src/lib/workers/ckdBlake2b.ts @@ -1,12 +1,15 @@ // SPDX-FileCopyrightText: 2024 Chris Duncan // SPDX-License-Identifier: GPL-3.0-or-later +import blake2b from 'blake2b' + async function ckdBlake2b () { - const { default: blake2b } = await import('blake2b') + let blake2b: any let addEventListener = globalThis.addEventListener let postMessage = globalThis.postMessage if (addEventListener == null || postMessage == null) { + blake2b = (await import('blake2b')).default const { isMainThread, parentPort } = await import('node:worker_threads') if (!isMainThread && parentPort) { addEventListener = Object.getPrototypeOf(parentPort).addListener.bind(parentPort) -- 2.34.1