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

Commit 4ec1315

Browse files
piougznck
andauthored
fix: avoid conflicting filename for sourcemaps (#375)
Co-authored-by: Rahul Kadyan <[email protected]>
1 parent cd41410 commit 4ec1315

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/index.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {
127127
if (block) {
128128
return {
129129
code: block.content,
130-
map: normalizeSourceMap(block.map),
130+
map: normalizeSourceMap(block.map, id),
131131
}
132132
}
133133
}
@@ -196,7 +196,7 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {
196196

197197
return {
198198
code: result.code,
199-
map: normalizeSourceMap(result.map!),
199+
map: normalizeSourceMap(result.map!, id),
200200
}
201201
} else if (query.type === 'style') {
202202
debug(`transform(${id})`)
@@ -263,7 +263,7 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {
263263
} else {
264264
return {
265265
code: result.code,
266-
map: normalizeSourceMap(result.map!),
266+
map: normalizeSourceMap(result.map!, id),
267267
}
268268
}
269269
}
@@ -638,9 +638,14 @@ function _(any: any) {
638638
return JSON.stringify(any)
639639
}
640640

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

644+
if (!id.includes('type=script')) {
645+
map.file = id;
646+
map.sources[0] = id;
647+
}
648+
644649
return {
645650
...map,
646651
version: Number(map.version),

0 commit comments

Comments
 (0)