Skip to content

Commit

Permalink
normalize file URLs to paths (important on windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
bengl committed Jun 2, 2023
1 parent 803e73e commit 0396249
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/get-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const getEsmExports = require('./get-esm-exports.js')
const { parse: getCjsExports }= require('cjs-module-lexer')
const fs = require('fs')
const { fileURLToPath } = require('url')

function addDefault(arr) {
return Array.from(new Set(['default', ...arr]))
Expand All @@ -25,7 +26,7 @@ async function getExports (url, context, parentLoad) {

if (!source) {
// Sometimes source is retrieved by parentLoad, sometimes it isn't.
source = fs.readFileSync(new URL(url).pathname, 'utf8')
source = fs.readFileSync(fileURLToPath(url), 'utf8')
}

if (format === 'module') {
Expand Down

0 comments on commit 0396249

Please sign in to comment.