Skip to content

Commit

Permalink
[fix] add filename to combined source map if needed (#6089)
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Jul 23, 2021
1 parent 176c92b commit 4ca2af4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/compiler/utils/mapped_code.ts
Expand Up @@ -251,6 +251,11 @@ export function combine_sourcemaps(

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

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

return map;
}

Expand Down
2 changes: 1 addition & 1 deletion test/sourcemaps/samples/preprocessed-no-map/_config.js
@@ -1,5 +1,5 @@
export default {
css_map_sources: [],
css_map_sources: ['input.svelte'],
preprocess: [
{
style: ({ content }) => {
Expand Down

0 comments on commit 4ca2af4

Please sign in to comment.