diff --git a/src/compiler/utils/mapped_code.ts b/src/compiler/utils/mapped_code.ts index 12a3ce1d162..58f44d7b8c9 100644 --- a/src/compiler/utils/mapped_code.ts +++ b/src/compiler/utils/mapped_code.ts @@ -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; } diff --git a/test/sourcemaps/samples/preprocessed-no-map/_config.js b/test/sourcemaps/samples/preprocessed-no-map/_config.js index 9888b56ddf8..78b0ee626f2 100644 --- a/test/sourcemaps/samples/preprocessed-no-map/_config.js +++ b/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 }) => {