Skip to content

Commit 4ca2af4

Browse files
authored
[fix] add filename to combined source map if needed (#6089)
1 parent 176c92b commit 4ca2af4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/compiler/utils/mapped_code.ts

+5
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ export function combine_sourcemaps(
251251

252252
if (!map.file) delete map.file; // skip optional field `file`
253253

254+
// When source maps are combined and the leading map is empty, sources is not set.
255+
// Add the filename to the empty array in this case.
256+
// Further improvements to remapping may help address this as well https://github.com/ampproject/remapping/issues/116
257+
if (!map.sources.length) map.sources = [filename];
258+
254259
return map;
255260
}
256261

test/sourcemaps/samples/preprocessed-no-map/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
css_map_sources: [],
2+
css_map_sources: ['input.svelte'],
33
preprocess: [
44
{
55
style: ({ content }) => {

0 commit comments

Comments
 (0)