Skip to content

Commit

Permalink
bundled
Browse files Browse the repository at this point in the history
Signed-off-by: duart38 <duartsnel@icloud.com>
  • Loading branch information
duart38 committed Sep 12, 2022
1 parent 920907e commit a68289f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Thread.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ class Thread {
blobURL = "";
stopped = false;
constructor(operation, type, imports){
imports?.forEach((v)=>{
if (v.endsWith(".ts'") || v.endsWith('.ts"')) {
throw new Error("Threaded imports do no support typescript files");
}
});
this.imports = imports || [];
this.blob = this.populateFile(operation);
this.worker = this.makeWorker(type);
Expand Down Expand Up @@ -41,7 +36,7 @@ class Thread {
]);
}
async copyDep(str) {
const importPathRegex = /('|"|`)(.+\.js)(\1)/ig;
const importPathRegex = /('|"|`)(.+(\.js|\.ts))(\1)/ig;
const importInsRegex = /(import( |))({.+}|.+)(from( |))/ig;
const matchedPath = importPathRegex.exec(str) || "";
let file = false;
Expand All @@ -58,7 +53,13 @@ class Thread {
const x = await import(fqfn);
return Object.keys(x).map((v)=>x[v].toString());
} else {
const x1 = await import(matchedPath[0].replaceAll(/'|"/g, ""));
const filePath = matchedPath[0].replaceAll(/'|"/g, "");
if (filePath.endsWith(".ts")) {
return [
str
];
}
const x1 = await import(filePath);
return Object.keys(x1).map((v)=>x1[v].toString());
}
}
Expand Down

0 comments on commit a68289f

Please sign in to comment.