From 4ca2af41df436ef97cd1953eb67c2c4922a8257b Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Fri, 23 Jul 2021 18:44:26 +0200 Subject: [PATCH] [fix] add filename to combined source map if needed (#6089) --- src/compiler/utils/mapped_code.ts | 5 +++++ test/sourcemaps/samples/preprocessed-no-map/_config.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/utils/mapped_code.ts b/src/compiler/utils/mapped_code.ts index 12a3ce1d16..58f44d7b8c 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 9888b56ddf..78b0ee626f 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 }) => {