Skip to content

Commit

Permalink
fix: ensure source and filename are known to compileModule's source map
Browse files Browse the repository at this point in the history
Similar to a change that was part of #10459

Fixes sveltejs/svelte-loader#238
  • Loading branch information
dummdidumm committed Oct 9, 2024
1 parent 0d3d5a2 commit c42361e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/beige-donkeys-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure source and filename are known to compileModule's source map
8 changes: 7 additions & 1 deletion packages/svelte/src/compiler/phases/3-transform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function transform_component(analysis, source, options) {
const js_source_name = get_source_name(options.filename, options.outputFilename, 'input.svelte');
const js = print(program, {
// include source content; makes it easier/more robust looking up the source map code
// (else esrap does return null for source and sourceMapContent which may trip up tooling)
sourceMapContent: source,
sourceMapSource: js_source_name
});
Expand Down Expand Up @@ -91,7 +92,12 @@ export function transform_module(analysis, source, options) {
}

return {
js: print(program, {}),
js: print(program, {
// include source content; makes it easier/more robust looking up the source map code
// (else esrap does return null for source and sourceMapContent which may trip up tooling)
sourceMapContent: source,
sourceMapSource: get_source_name(options.filename, undefined, 'input.svelte.js')
}),
css: null,
metadata: {
runes: true
Expand Down

0 comments on commit c42361e

Please sign in to comment.