77
88// LLVM => JavaScript compiler, main entry point
99
10- const fs = require ( 'fs' ) ;
11- globalThis . vm = require ( 'vm' ) ;
12- globalThis . assert = require ( 'assert' ) ;
13- globalThis . nodePath = require ( 'path' ) ;
10+ import * as fs from 'fs' ;
11+ import * as path from 'path' ;
12+ import * as vm from 'vm' ;
13+ import * as url from 'url' ;
14+ import assert from 'assert' ;
15+
16+ globalThis . vm = vm ;
17+ globalThis . assert = assert ;
18+ globalThis . nodePath = path ;
1419
1520globalThis . print = ( x ) => {
1621 process . stdout . write ( x + '\n' ) ;
@@ -22,9 +27,10 @@ globalThis.printErr = (x) => {
2227
2328function find ( filename ) {
2429 assert ( filename ) ;
25- const prefixes = [ __dirname , process . cwd ( ) ] ;
30+ const dirname = url . fileURLToPath ( new URL ( '.' , import . meta. url ) ) ;
31+ const prefixes = [ dirname , process . cwd ( ) ] ;
2632 for ( let i = 0 ; i < prefixes . length ; ++ i ) {
27- const combined = nodePath . join ( prefixes [ i ] , filename ) ;
33+ const combined = path . join ( prefixes [ i ] , filename ) ;
2834 if ( fs . existsSync ( combined ) ) {
2935 return combined ;
3036 }
@@ -96,7 +102,7 @@ if (!STRICT) {
96102// Main
97103// ===============================
98104
99- B = new Benchmarker ( ) ;
105+ const B = new Benchmarker ( ) ;
100106
101107try {
102108 runJSify ( ) ;
0 commit comments