Skip to content

Source maps include preprocessed source instead of original #171

Closed
@ghost

Description

Describe the bug
I am using Svelte, TypeScript and Webpack. As far as I understand the source map feature implemented in sveltejs/svelte#5584, Svelte should transform the source map generated by TypeScript (via svelte-preprocess) into the final source map. This is not the case, apparently the source map contains the preprocessed JavaScript output. For example, the following Svelte component:

<script lang="ts">
  let name: string = 'world';

  console.log("This is App.svelte, line 4!");
</script>

<main>
  Hello {name}!
</main>

results in the following content in the sourcemap:

<script lang="ts">let name = 'world';
console.log("This is App.svelte, line 4!");
</script>

<main>
  Hello {name}!
</main>

Logs
The log line in the developer console reads This is App.svelte, line 4! [...] App.svelte:2:8.

To Reproduce
Clone this repository: https://github.com/baileyherbert/svelte-webpack-starter
Update to the latest Svelte version (npm update) and run the server npm run dev. View the source content in the browser console.

Expected behavior
I would expect the original TypeScript source to be contained in the source map. The line/col mappings should refer to the original locations in App.svelte.

Information about your Svelte project:

  • Firefox 78.8.0esr
  • Debian Linux 10
  • Svelte version 3.35.0
  • svelte-preprocess 4.6.9
  • svelte-loader 3.0.0
  • TypeScript 4.2.3
  • Webpack 5.26.2

Severity
Severity: Only annoying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions