Sourcemaps stop working due to multiline comment + CRLF line endings
See original GitHub issueWhat 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:
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:
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:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.