Skip to content

Commit

Permalink
Fix #1060
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed Jul 29, 2020
1 parent cc364bf commit f76dfce
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import sourceMapSupport = require('source-map-support')
import * as ynModule from 'yn'
import { BaseError } from 'make-error'
import * as util from 'util'
import {fileURLToPath} from 'url'
import * as _ts from 'typescript'

/**
Expand Down Expand Up @@ -445,8 +446,18 @@ export function create (rawOptions: CreateOptions = {}): Register {
// Install source map support and read from memory cache.
sourceMapSupport.install({
environment: 'node',
retrieveFile (path: string) {
return outputCache.get(normalizeSlashes(path))?.content || ''
retrieveFile (pathOrUrl: string) {
let path = pathOrUrl
// If it's a file URL, convert to local path
// Note: fileURLToPath does not exist on early node v10
// I could not find a way to handle non-URLs except to swallow an error
if(fileURLToPath && path.startsWith('file://')) {
try {
path = fileURLToPath(path)
} catch (e) {}
}
path = normalizeSlashes(path)
return outputCache.get(path)?.content || ''
}
})

Expand Down

0 comments on commit f76dfce

Please sign in to comment.