From c42361e583739d6bb3e87e019fe938655f97d62a Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Wed, 9 Oct 2024 21:41:00 +0200 Subject: [PATCH] fix: ensure source and filename are known to compileModule's source map Similar to a change that was part of #10459 Fixes https://github.com/sveltejs/svelte-loader/issues/238 --- .changeset/beige-donkeys-exercise.md | 5 +++++ packages/svelte/src/compiler/phases/3-transform/index.js | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/beige-donkeys-exercise.md diff --git a/.changeset/beige-donkeys-exercise.md b/.changeset/beige-donkeys-exercise.md new file mode 100644 index 000000000000..d0137b361548 --- /dev/null +++ b/.changeset/beige-donkeys-exercise.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure source and filename are known to compileModule's source map diff --git a/packages/svelte/src/compiler/phases/3-transform/index.js b/packages/svelte/src/compiler/phases/3-transform/index.js index c752b005c392..8f6597ee1298 100644 --- a/packages/svelte/src/compiler/phases/3-transform/index.js +++ b/packages/svelte/src/compiler/phases/3-transform/index.js @@ -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 }); @@ -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