Skip to content

Commit

Permalink
fix: fix sourceMap path separator on Windows, default sourceRoot to "" (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
3cp authored and znck committed Jan 14, 2019
1 parent 0626cad commit df32cd9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function parse(options: ParseOptions): SFCDescriptor {
filename = '',
compiler,
compilerParseOptions = { pad: 'line' },
sourceRoot = process.cwd(),
sourceRoot = '',
needMap = true
} = options
const cacheKey = hash(filename + source)
Expand Down Expand Up @@ -89,8 +89,8 @@ function generateSourceMap(
sourceRoot: string
): RawSourceMap {
const map = new SourceMapGenerator({
file: filename,
sourceRoot
file: filename.replace(/\\/g, '/'),
sourceRoot: sourceRoot.replace(/\\/g, '/')
})
map.setSourceContent(filename, source)
generated.split(splitRE).forEach((line, index) => {
Expand Down

0 comments on commit df32cd9

Please sign in to comment.