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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments break source maps in TypeScript #7664

Closed
smoli opened this issue Feb 7, 2022 · 2 comments
Closed

Comments break source maps in TypeScript #7664

smoli opened this issue Feb 7, 2022 · 2 comments

Comments

@smoli
Copy link

smoli commented Feb 7, 2022

馃悰 bug report

I have a simple project with no parcel config using TypeScript and vue. Having a comment in a ts file breaks the sourcemaps and the line mapping is wrong.

Repository that consistently reproduces the behavior: https://github.com/smoli/parcelSourceMapError

  • Just run parcel. (npm start)
  • Open the webpage
  • Click one of the buttons.
  • In console, click on the source-location for the "DEBUG!" output
    --> The output is associated with the wrong line number.

image

Tested on Chrome 97 and Firefox 96

Turning off HMR does not help.

This is so simple to reproduce, I might do something wrong?

馃帥 Configuration (.babelrc, package.json, cli command)

There is no config, neither for parcel nor for ts.

Find a repository here, that reproduces the problem: https://github.com/smoli/parcelSourceMapError

package.json

{
  "name": "parcelSourceMaps",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start": "parcel ./src/index.html",
    "startNoHMR": "parcel ./src/index.html --no-hmr"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "vue": "^3.2.29",
    "vuex": "^4.0.2"
  },
  "devDependencies": {
    "@parcel/transformer-vue": "^2.2.1",
    "parcel": "^2.2.1"
  }
}

馃 Expected Behavior

Lines given on console output should match the source position where the console-statement was issued. This translates to break points and debugger statements.

馃槸 Current Behavior

Source lines are offset when comments are present in the file.

馃拋 Possible Solution

See comment below

馃敠 Context

Makes debugging in large projects impossible.

馃捇 Code Sample

https://github.com/smoli/parcelSourceMapError

馃實 Your Environment

Software Version(s)
Parcel 2.2.1
Node 16.13.2
npm/Yarn npm 8.1.2
Operating System Win10
@smoli
Copy link
Author

smoli commented Feb 7, 2022

I found a fix by using

parcel-transformer-tsc-sourcemaps

and setting removeComments: true in tsconfig.json

See branch fixedbyremovingcomments in the demo project.

As I understand it this fix should be preliminary as parcel-transformer-tsc-sourcemaps is preliminary to mitigate #7570

Maybe this gives some more insight into the problem. Seems as if comments might be considered twice when creating the sourcemaps.

Thanks to @iSplasher and @ImpendingDoom28

@eco747
Copy link

eco747 commented Feb 11, 2022

idem #7655

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

No branches or pull requests

3 participants