File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,6 @@ class Thread {
99 blobURL = "" ;
1010 stopped = false ;
1111 constructor ( operation , type , imports ) {
12- imports ?. forEach ( ( v ) => {
13- if ( v . endsWith ( ".ts'" ) || v . endsWith ( '.ts"' ) ) {
14- throw new Error ( "Threaded imports do no support typescript files" ) ;
15- }
16- } ) ;
1712 this . imports = imports || [ ] ;
1813 this . blob = this . populateFile ( operation ) ;
1914 this . worker = this . makeWorker ( type ) ;
@@ -41,7 +36,7 @@ class Thread {
4136 ] ) ;
4237 }
4338 async copyDep ( str ) {
44- const importPathRegex = / ( ' | " | ` ) ( .+ \. j s ) ( \1) / ig;
39+ const importPathRegex = / ( ' | " | ` ) ( .+ ( \. j s | \. t s ) ) ( \1) / ig;
4540 const importInsRegex = / ( i m p o r t ( | ) ) ( { .+ } | .+ ) ( f r o m ( | ) ) / ig;
4641 const matchedPath = importPathRegex . exec ( str ) || "" ;
4742 let file = false ;
@@ -58,7 +53,13 @@ class Thread {
5853 const x = await import ( fqfn ) ;
5954 return Object . keys ( x ) . map ( ( v ) => x [ v ] . toString ( ) ) ;
6055 } else {
61- const x1 = await import ( matchedPath [ 0 ] . replaceAll ( / ' | " / g, "" ) ) ;
56+ const filePath = matchedPath [ 0 ] . replaceAll ( / ' | " / g, "" ) ;
57+ if ( filePath . endsWith ( ".ts" ) ) {
58+ return [
59+ str
60+ ] ;
61+ }
62+ const x1 = await import ( filePath ) ;
6263 return Object . keys ( x1 ) . map ( ( v ) => x1 [ v ] . toString ( ) ) ;
6364 }
6465 }
You can’t perform that action at this time.
0 commit comments