diff --git a/packages/svelte/src/compiler/phases/3-transform/client/utils.js b/packages/svelte/src/compiler/phases/3-transform/client/utils.js index 1194cffcde..05633632c1 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/utils.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/utils.js @@ -288,7 +288,8 @@ function get_hoistable_params(node, context) { params.push(b.id(binding.node.name.slice(1))); params.push(b.id(binding.node.name)); } else { - params.push(binding.node); + // create a copy to remove start/end tags which would mess up source maps + params.push(b.id(binding.node.name)); } } } diff --git a/playgrounds/sandbox/run.js b/playgrounds/sandbox/run.js index 15cdc0e8b8..7cfe4eff63 100644 --- a/playgrounds/sandbox/run.js +++ b/playgrounds/sandbox/run.js @@ -35,6 +35,7 @@ for (const generate of ['client', 'server']) { const source = fs.readFileSync(input, 'utf-8'); const output_js = `${cwd}/output/${generate}/${file}.js`; + const output_map = `${cwd}/output/${generate}/${file}.js.map`; const output_css = `${cwd}/output/${generate}/${file}.css`; mkdirp(path.dirname(output_js)); @@ -54,7 +55,11 @@ for (const generate of ['client', 'server']) { runes: argv.runes }); - fs.writeFileSync(output_js, compiled.js.code); + fs.writeFileSync( + output_js, + compiled.js.code + '\n//# sourceMappingURL=' + path.basename(output_map) + ); + fs.writeFileSync(output_map, compiled.js.map.toString()); if (compiled.css) { fs.writeFileSync(output_css, compiled.css.code); }