Skip to content

Commit 599f28b

Browse files
authored
Use file URL for source map paths (#1771)
1 parent 04f4c28 commit 599f28b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/index.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { relative, basename, extname, dirname, join } from 'path';
1+
import { relative, basename, extname, dirname, join, isAbsolute } from 'path';
22
import { Module } from 'module';
33
import * as util from 'util';
4-
import { fileURLToPath } from 'url';
4+
import { fileURLToPath, pathToFileURL } from 'url';
55

66
import type * as _sourceMapSupport from '@cspotcode/source-map-support';
77
import { BaseError } from 'make-error';
@@ -1667,8 +1667,11 @@ function updateOutput(
16671667
*/
16681668
function updateSourceMap(sourceMapText: string, fileName: string) {
16691669
const sourceMap = JSON.parse(sourceMapText);
1670-
sourceMap.file = fileName;
1671-
sourceMap.sources = [fileName];
1670+
const outputFileName = isAbsolute(fileName)
1671+
? pathToFileURL(fileName).href
1672+
: fileName;
1673+
sourceMap.file = outputFileName;
1674+
sourceMap.sources = [outputFileName];
16721675
delete sourceMap.sourceRoot;
16731676
return JSON.stringify(sourceMap);
16741677
}

0 commit comments

Comments
 (0)