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

HTML comment causes misaligned sourcemap #3906

Closed
btamas opened this issue Nov 12, 2019 · 4 comments
Closed

HTML comment causes misaligned sourcemap #3906

btamas opened this issue Nov 12, 2019 · 4 comments

Comments

@btamas
Copy link

btamas commented Nov 12, 2019

In our project we should add license headers to source files, but when I did that in our first .svelte file, I experienced the generated sourcemap is incorrect and it ignores the comments.
It makes the debugging more difficult and the test coverage result is useless as well.

Svelte version: 3.14.0

Example .svelte source:

<!-- Some comment
and more
and more details -->
<script>
  const test = () => {
    console.log('test');
  }
</script>

When I want to debug test variable it points to the 2. line of the .svelte file.
This tool can help to visualize source map: http://evanw.github.io/source-map-visualization/

If I add the comment into the script tag, it works without any problem, but it looks stupid.

@tionkje
Copy link

tionkje commented Dec 13, 2019

Seems like anu svelte file where the script tag is not on the first line the sourcemap is off.
Like when adding a second script tag with context="module" the second script tag in the file is off by the amount of lines before that script tag.

@red8012
Copy link

red8012 commented Dec 16, 2019

Confirmed. Anything (even a blank line) goes before the script tag will cause the sourcemap line number to be incorrect.

@weepy
Copy link

weepy commented Feb 12, 2020

I have this issue if I put a <style> tag at the top of the component. I've fixed by moving the <style> to the end, but it's obviously a bit odd.

@Conduitry
Copy link
Member

This should be fixed now in 3.22.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants