Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filename to combined source map if needed #6089

Merged
merged 3 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/compiler/utils/mapped_code.ts
Original file line number Diff line number Diff line change
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.
// Possibly a bug in the remapping library https://github.com/ampproject/remapping/issues/116
benmccann marked this conversation as resolved.
Show resolved Hide resolved
if (!map.sources.length) map.sources = [filename];

return map;
}

Expand Down
2 changes: 1 addition & 1 deletion test/sourcemaps/samples/decoded-sourcemap/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { magic_string_preprocessor_result, magic_string_replace_all } from '../.

export default {

js_map_sources: [], // test component has no scripts
js_map_sources: ['input.svelte'],

preprocess: {
markup: ({ content, filename }) => {
Expand Down
2 changes: 1 addition & 1 deletion test/sourcemaps/samples/external/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const STYLES = '.awesome { color: orange; }\n';

export default {
css_map_sources: ['common.scss', 'styles.scss'],
js_map_sources: [],
js_map_sources: ['input.svelte'],
preprocess: [
{
style: () => {
Expand Down
2 changes: 1 addition & 1 deletion test/sourcemaps/samples/preprocessed-no-map/_config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
css_map_sources: [],
css_map_sources: ['input.svelte'],
preprocess: [
{
style: ({ content }) => {
Expand Down
2 changes: 1 addition & 1 deletion test/sourcemaps/samples/sourcemap-basename/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ span {

export default {
css_map_sources: [external_relative_filename],
js_map_sources: [],
js_map_sources: ['input.svelte'],
preprocess: [
{
style: ({ content, filename }) => {
Expand Down
2 changes: 1 addition & 1 deletion test/sourcemaps/samples/sourcemap-offsets/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { magic_string_bundle } from '../../helpers';
export const EXTERNAL = 'span { --external-var: 1px; }';

export default {
js_map_sources: [],
js_map_sources: ['input.svelte'],
css_map_sources: ['input.svelte', 'external.css'],
preprocess: [
{
Expand Down