Skip to content

Commit 6776947

Browse files
authored
fix: ensure source and filename are known to compileModule's source map (#13546)
Similar to a change that was part of #10459 Fixes sveltejs/svelte-loader#238
1 parent 0d3d5a2 commit 6776947

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/beige-donkeys-exercise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure source and filename are known to compileModule's source map

packages/svelte/src/compiler/phases/3-transform/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function transform_component(analysis, source, options) {
3535
const js_source_name = get_source_name(options.filename, options.outputFilename, 'input.svelte');
3636
const js = print(program, {
3737
// include source content; makes it easier/more robust looking up the source map code
38+
// (else esrap does return null for source and sourceMapContent which may trip up tooling)
3839
sourceMapContent: source,
3940
sourceMapSource: js_source_name
4041
});
@@ -91,7 +92,12 @@ export function transform_module(analysis, source, options) {
9192
}
9293

9394
return {
94-
js: print(program, {}),
95+
js: print(program, {
96+
// include source content; makes it easier/more robust looking up the source map code
97+
// (else esrap does return null for source and sourceMapContent which may trip up tooling)
98+
sourceMapContent: source,
99+
sourceMapSource: get_source_name(options.filename, undefined, 'input.svelte.js')
100+
}),
95101
css: null,
96102
metadata: {
97103
runes: true

0 commit comments

Comments
 (0)