Skip to content

Commit dad4b36

Browse files
authored
Fix CJS __dirname interop on windows (#204)
1 parent 72cbb6b commit dad4b36

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

build.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ function patchCjsInterop() {
4646
let code = [
4747
`import {createRequire} from 'module'`,
4848
`import {dirname as __global__dirname__} from 'path'`,
49+
`import {fileURLToPath} from 'url'`,
4950

5051
// CJS interop fixes
5152
`const require=createRequire(import.meta.url)`,
52-
`const __filename=new URL(import.meta.url).pathname`,
53+
`const __filename=fileURLToPath(import.meta.url)`,
5354
`const __dirname=__global__dirname__(__filename)`,
5455
]
5556

0 commit comments

Comments
 (0)