question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sourcemaps stop working due to multiline comment + CRLF line endings

See original GitHub issue

What version of Next.js are you using?

Happens in at least 12.0.0, 12.0.7, 12.0.8-canary.5 and 12.0.8-canary.8.

What version of Node.js are you using?

16.13.1

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

next dev

Describe the Bug

When my function has a multiline comment, sourcemaps break. I can’t set a breakpoint on the first console.log and the variables in “Scope” make no sense: image

Expected Behavior

I expected the same behavior as when the multiline comment is removed, so being able to set a breakpoint on the first console.log and the “Scope” looking like this: image

To Reproduce

  • Clone https://github.com/leroydev/nextjs-sourcemaps (it’s a minimal working example, just 1 extra commit on top of npx create-next-app@latest --ts)
  • Execute yarn to install the dependencies
  • Run yarn dev to start Next.js in development
  • Open http://localhost:3000
  • Open Chrome DevTools -> CTRL + P -> LogSomeText.ts
  • Set breakpoints inside the function and reload

You can see that when you completely remove the multiline comment in LogSomeText.ts, you can set a breakpoint on the first console.log again and the variables in the scope make sense again.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
leroydevcommented, Dec 15, 2021

I think this might possibly be fixed in https://github.com/swc-project/swc/pull/3023, which has been released in swc_ecma_codegen 0.83.2. I can’t get a local Next.js version to work with a custom SWC build though, so I unfortunately can’t verify this.

1reaction
balazsorban44commented, Dec 14, 2021

I am on Linux, and I used your reproduction.

You are correct though, I could reproduce it by changing the line ending to CRLF and resave the LogSomeText.ts file.

It happens when using the SWC transform.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Any subtleties in source map line/column definitions when ...
I am getting a code generator to produce source maps that tracks line/column based on Unicode code-points with lines broken by (LF, CR, ......
Read more >
4 Reasons Why Your Source Maps are Broken - Sentry Blog
In a sense, source maps are the decoder ring to your secret (minified) code. However, they can be tricky to get working properly....
Read more >
clean-css - npm
Start using clean-css in your project by running `npm i clean-css`. ... 2}} means clean-css will add two line breaks after each comment...
Read more >
node_modules/clean-css - Pierre GAMBAROTTO - PLMlab
How to preserve a comment block? How to rebase relative image URLs? How to work with source maps? How to apply level 1...
Read more >
PyCharm 181.5540.17 Release Notes | Knowledge Base
Docker, Bug, PY-29384, PyCharm doesn't stop containers ... Bug, IDEA-192328, Entering a newline between a regular multiline comment and doc comment ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found