Skip to content

Commit df32cd9

Browse files
3cpznck
authored andcommitted
fix: fix sourceMap path separator on Windows, default sourceRoot to "" (#51)
This enforces separator '/' is used for any OS. It also changed sourceRoot default value from process.cwd() to empty string, because local directory is irrelevant in browser where sourceMap is consumed. closes #47
1 parent 0626cad commit df32cd9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/parse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function parse(options: ParseOptions): SFCDescriptor {
4949
filename = '',
5050
compiler,
5151
compilerParseOptions = { pad: 'line' },
52-
sourceRoot = process.cwd(),
52+
sourceRoot = '',
5353
needMap = true
5454
} = options
5555
const cacheKey = hash(filename + source)
@@ -89,8 +89,8 @@ function generateSourceMap(
8989
sourceRoot: string
9090
): RawSourceMap {
9191
const map = new SourceMapGenerator({
92-
file: filename,
93-
sourceRoot
92+
file: filename.replace(/\\/g, '/'),
93+
sourceRoot: sourceRoot.replace(/\\/g, '/')
9494
})
9595
map.setSourceContent(filename, source)
9696
generated.split(splitRE).forEach((line, index) => {

0 commit comments

Comments
 (0)