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

JSDoc causing wrong line number in Chrome console #8753

Closed
calebfoss opened this issue Jan 5, 2023 · 2 comments
Closed

JSDoc causing wrong line number in Chrome console #8753

calebfoss opened this issue Jan 5, 2023 · 2 comments

Comments

@calebfoss
Copy link

🐛 bug report

🎛 Configuration (.babelrc, package.json, cli command)

package.json

{
  "name": "parcel_jsdoc_test",
  "version": "1.0.0",
  "description": "",
  "source": "test.js",
  "main": "dist/test.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@parcel/reporter-sourcemap-visualiser": "^2.8.2",
    "parcel": "^2.8.2"
  }
}

🤔 Expected Behavior

When I add JSDoc inline tags, I expect the line numbers in the browser console to remain consistent with the line numbers in the original file.

😯 Current Behavior

When I build the sample code below and run it in Chrome, it logs CHECK1 and CHECK3 at the correct line number, but logs CHECK2 at line 8 when it should be line 7. If I run the same code in Firefox or delete the source map file and run in Chrome, the issue goes away.

I'm guessing that JSDoc syntax is interfering with the way Parcel generates source maps.

💁 Possible Solution

???

🔦 Context

I'm working on documenting a library with JSDoc, and console logs and error messages are now way out of sync with the source.

💻 Code Sample

console.log("CHECK1");
/**
 * Description
 * @class Test
 */
class Test {}
console.log("CHECK2");
console.log("CHECK3");

🌍 Your Environment

Software Version(s)
Parcel 2.8.2
Node 14.18.1
npm/Yarn npm 6.14.15
Operating System Windows 10
@mischnic
Copy link
Member

mischnic commented Jan 6, 2023

Try saving the file with Unix line endings instead of Windows line endings as a workaround (and to verify that this is indeed the issue)
Related in that case: #8302, #8691, swc-project/swc#6694

@calebfoss
Copy link
Author

Yes, that's it! I verified that switching from CRLF to LF fixes the issue on this test as well as on my project. Thank you for the quick response!

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

2 participants