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

Invalid sourcemaps with template literal #8302

Closed
mischnic opened this issue Jul 12, 2022 · 3 comments · Fixed by #8756
Closed

Invalid sourcemaps with template literal #8302

mischnic opened this issue Jul 12, 2022 · 3 comments · Fixed by #8756

Comments

@mischnic
Copy link
Member

mischnic commented Jul 12, 2022

After some heavy debugging I figured out.
If you are using Template literals (``) the source map is completely broken.

index.ts

 console.log("test1") // line 1 correct

let text = `
    1
    1
    1
    1
    1
    1
    `

console.log("test2") // this should be line 12, instead 17 in devtools

let test0
let test1

console.log("test3")  // this only woks because last line if you add more content it wont work

index.html

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
	</head>
	<body>
		<script src="./index.ts"></script>
	</body>
</html>

Devtools
image

Originally posted by @Levminer in #5815 (comment)

@mischnic
Copy link
Member Author

mischnic commented Jul 12, 2022

When using Windows line endings (cr + lf), the sourcemaps are wrong:

Bildschirmfoto 2022-07-12 um 14 23 43

@Levminer
Copy link

As a workaround setting line endings LF in vs code fixes this, thanks for the help!

@mm-dsibinski
Copy link

Thanks, God, I found this issue! 😀 Was struggling with weird debugging issues and totally wrong source maps...
Changing CRLF to LF line endings is a workaround, but this should really be fixed.

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

Successfully merging a pull request may close this issue.

3 participants