Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
fix: avoid conflicting filename for sourcemaps (#375)
Browse files Browse the repository at this point in the history
Co-authored-by: Rahul Kadyan <hi@znck.me>
  • Loading branch information
pioug and znck authored Oct 22, 2020
1 parent cd41410 commit 4ec1315
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {
if (block) {
return {
code: block.content,
map: normalizeSourceMap(block.map),
map: normalizeSourceMap(block.map, id),
}
}
}
Expand Down Expand Up @@ -196,7 +196,7 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {

return {
code: result.code,
map: normalizeSourceMap(result.map!),
map: normalizeSourceMap(result.map!, id),
}
} else if (query.type === 'style') {
debug(`transform(${id})`)
Expand Down Expand Up @@ -263,7 +263,7 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {
} else {
return {
code: result.code,
map: normalizeSourceMap(result.map!),
map: normalizeSourceMap(result.map!, id),
}
}
}
Expand Down Expand Up @@ -638,9 +638,14 @@ function _(any: any) {
return JSON.stringify(any)
}

function normalizeSourceMap(map: SFCTemplateCompileResults['map']): any {
function normalizeSourceMap(map: SFCTemplateCompileResults['map'], id: string): any {
if (!map) return null as any

if (!id.includes('type=script')) {
map.file = id;
map.sources[0] = id;
}

return {
...map,
version: Number(map.version),
Expand Down

0 comments on commit 4ec1315

Please sign in to comment.