Skip to content

Commit

Permalink
Fix CJS __dirname interop on windows (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
YannicEl committed Aug 14, 2023
1 parent 72cbb6b commit dad4b36
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ function patchCjsInterop() {
let code = [
`import {createRequire} from 'module'`,
`import {dirname as __global__dirname__} from 'path'`,
`import {fileURLToPath} from 'url'`,

// CJS interop fixes
`const require=createRequire(import.meta.url)`,
`const __filename=new URL(import.meta.url).pathname`,
`const __filename=fileURLToPath(import.meta.url)`,
`const __dirname=__global__dirname__(__filename)`,
]

Expand Down

0 comments on commit dad4b36

Please sign in to comment.