compatibility on worker resolution

This commit is contained in:
Pierre-Henri
2024-04-21 14:59:28 +02:00
parent 68e4689fe8
commit 66b3d5c5f2
+8 -8
View File
@@ -1,21 +1,21 @@
import {Piscina} from "piscina";
import {CID_ALGORITHM_NAMES} from "../hash-compute/MultiHashData";
import {FileIDComputerInterface} from "@root/file-id/FileIDComputerInterface";
// Construct the URL for the current module
let distFolder = import.meta.dirname;
distFolder = distFolder.replace('src', 'dist');
distFolder = distFolder + "/worker.js";
const workerUrl = new URL(distFolder).href;
export class FileIDComputerWorker{
private piscina: Piscina;
constructor(workerPath?:string) {
if(!workerPath) {
// Construct the URL for the current module
let distFolder = import.meta.dirname;
distFolder = distFolder.replace('src', 'dist');
distFolder = distFolder + "/worker.js";
workerPath = new URL(distFolder,"file://").href;
}
this.piscina = new Piscina({
maxThreads: 4,
//filename: new URL('./ShaComputeWorker.ts', import.meta.url).href
filename: workerPath || process.env.WORKER_URL || workerUrl
filename: workerPath
});
}