sveltejs/svelte-loader

Debugging source maps issue and possible fix

madisc opened this issue · 0 comments

I'm using vscode to debug, and previously used rollup which worked. When I changed to webpack the svelte breakpoints weren't hit when using Svelte Preprocess (without was fine). I found adding this line makes it work:

if (!js.map.sourcesContent) {
    js.map.sourcesContent = [source];
  + js.map.sources = [compileOptions.filename] // ADD THIS
};

This may be a hacky solution, and I haven't tested it thoroughly, but Svelte breakpoints are now being hit. Hope this helps if anyone has been having similar issues.

Libs:

svelte 3.37.0
svelte-preprocess 4.7.2
svelte-loader 3.1.1
webpack 5.36.1