From df32cd9427ca35be56ce8ef345d4705f12e83438 Mon Sep 17 00:00:00 2001 From: huochunpeng Date: Tue, 15 Jan 2019 09:25:50 +1100 Subject: [PATCH] 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 --- lib/parse.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/parse.ts b/lib/parse.ts index 8fbd70e..cd835f3 100644 --- a/lib/parse.ts +++ b/lib/parse.ts @@ -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) @@ -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) => {