Skip to content

Commit

Permalink
fix: remove protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Nov 1, 2023
1 parent 0b8bdaa commit 3523a6a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/vite-node/src/externalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ async function isValidNodeImport(id: string, code?: string) {
if (package_.type === 'module')
return true

if (typeof code === 'undefined')
code = await fsp.readFile(id, 'utf8').catch(() => '')
if (typeof code === 'undefined') {
code = await fsp.readFile(id.replace('file:///', ''), 'utf8').catch((err) => {
// FIXME: test
// eslint-disable-next-line no-console
console.log('Failed to read file:', id, err)
return ''
})
}

return !ESM_SYNTAX_RE.test(code)
}
Expand Down

0 comments on commit 3523a6a

Please sign in to comment.