File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
- import URL , { fileURLToPath } from 'node:url' ;
17
+ import URL , { fileURLToPath } from 'url' ;
18
+ import fs from 'fs' ;
18
19
import VM from 'vm' ;
19
20
import threads from 'worker_threads' ;
20
21
@@ -192,7 +193,7 @@ function workerThread() {
192
193
evaluateDataUrl ( mod , name ) ;
193
194
}
194
195
else {
195
- require ( mod ) ;
196
+ importScripts ( mod ) ;
196
197
}
197
198
}
198
199
catch ( err ) {
@@ -221,3 +222,17 @@ function parseDataUrl(url) {
221
222
}
222
223
return { type, data } ;
223
224
}
225
+
226
+ function importScripts ( ) {
227
+ for ( let i = 0 ; i < arguments . length ; i ++ ) {
228
+ const url = arguments [ i ] ;
229
+ let code ;
230
+ if ( / ^ d a t a : / . test ( url ) ) {
231
+ code = parseDataUrl ( url ) . data ;
232
+ }
233
+ else {
234
+ code = fs . readFileSync ( url , 'utf-8' ) ;
235
+ }
236
+ VM . runInThisContext ( code , { filename : url } ) ;
237
+ }
238
+ }
You can’t perform that action at this time.
0 commit comments