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

fix: Prevent conflicting filename for sourcemaps #375

Merged
merged 2 commits into from Oct 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/index.ts
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 @@ -192,7 +192,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 @@ -259,7 +259,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 @@ -634,9 +634,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