Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte 5: Inaccurate source maps when lang="ts" is enabled #9961

Open
AdrianGonz97 opened this issue Dec 19, 2023 · 3 comments
Open

Svelte 5: Inaccurate source maps when lang="ts" is enabled #9961

AdrianGonz97 opened this issue Dec 19, 2023 · 3 comments
Assignees
Labels
Milestone

Comments

@AdrianGonz97
Copy link
Member

AdrianGonz97 commented Dec 19, 2023

Describe the bug

Source maps are seemingly inaccurate when lang="ts" is enabled on the <script> tag. This only occurs when using TS in Svelte 5. Removing lang="ts" fixes the issue.

When presented with the following Svelte code:

img

Errors locations are accurate in the IDE (as shown above), but are off in both the terminal output, and the error page.

img

Reproduction

https://github.com/AdrianGonz97/svelte-5-ts-source-maps-reproduction

Logs

No response

System Info

  System:
    OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 7.95 GB / 31.30 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.volta/tools/image/node/20.10.0/bin/node
    Yarn: 1.22.21 - ~/.volta/tools/image/yarn/1.22.21/bin/yarn
    npm: 10.2.3 - ~/.volta/tools/image/node/20.10.0/bin/npm
    pnpm: 8.10.5 - ~/.volta/bin/pnpm
    bun: 1.0.2 - ~/.bun/bin/bun
  npmPackages:
    svelte: ^5.0.0-next.26 => 5.0.0-next.26

Severity

annoyance

@AdrianGonz97
Copy link
Member Author

Removing vitePreprocess from the preprocess array in svelte.config.js seems to also fix the source maps. Perhaps the issue is originating from there?

@dummdidumm
Copy link
Member

Sourcemaps with TS should work as of #10459

@AdrianGonz97
Copy link
Member Author

Thanks for taking a look, @dummdidumm!

Unfortunately, the issue is still present even with the latest version of Svelte 5. I've updated the dependencies in the reproduction if you'd like to check it out.

However, since messing with the preprocess field here:

Removing vitePreprocess from the preprocess array in svelte.config.js seems to also fix the source maps. Perhaps the issue is originating from there?

I'm thinking that the sourcemaps may actually be borked from the vite-plugin-svelte layer instead. Although, I'm unsure as to why the error highlighting in the IDE vs. the error window that appears on the site (as shown in images of the original issue above) are different from each other 🤔

@dummdidumm dummdidumm reopened this Mar 7, 2024
@dummdidumm dummdidumm added this to the 5.0 milestone Mar 7, 2024
@dummdidumm dummdidumm self-assigned this Mar 7, 2024
@dummdidumm dummdidumm added the bug label May 16, 2024
@Rich-Harris Rich-Harris modified the milestones: 5.0, 5.x Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants