-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Wrong line numbers when processing files after ts-loader #12025
Comments
I think it is expected, because resolving based on outputed file from loader, but yes, we can improve this, something like:
|
In this case it seems to be simple, but in a real project it's quite confusing if you look at the reported line and cannot find the cause. In theory the transpiled .js could be reported (instead of .ts), but since this does not exist to have a look at for reference this is not quite helpful as well. |
Yep, it will be great to improve this |
Assign it to me so that I can try to solve this. |
But which loader are you using to process typescript @jeffrson |
Just ts-loader |
ts-loader is a custom package created by TypeStrong. Its not a webpack owned loader in Webpack-contrib Github account. |
This issue had no activity for at least three months. It's subject to automatic issue closing if there is no activity in the next 15 days. |
Issue was closed because of inactivity. If you think this is still a valid issue, please file a new issue with additional information. |
Still valid, we can get real position from source map, if they present |
Is there a workaround ? Or do we need to wait for this to be completed? |
ts-loader makes wrong source map line/column numbers. |
Since the other issue is closed does this mean there won't be any fix? |
I had a chance to work a bit on this issue. I'm able to get the original lines and locations of the error using the source map as @alexander-akait advised. I used source-map library for the conversion, but I wonder where is the right place to do it. For example it could be done here for the Lines 2094 to 2098 in 0bc85d1
I could update the dependency location ( |
I think we should do it after loader processing |
I've been working on this problem since last week trying to find possible solutions. I'm still familiarizing myself with the codebase so I'm definitely open for feedback. Just to ensure I'm on the same page, I'd like to briefly describe the issue:
// Check if source map is present
if (this.originalSource().map()) {
this.dependencies.map(dep => convertLineNumbers(dep))
} Lines 1108 to 1120 in 0bc85d1
dependencies.map(dep => convertLineNumbers(dep)) Lines 2093 to 2100 in 0bc85d1
|
The first solution looks good, but let's it do only for errored modules |
In order to confine the fix to errored modules only as @alexander-akait suggested, I deferred updating the error location to the module factorization. |
This should still be open, right @log101? |
@jssuttles I guess so, no PR's referencing this issue has been merged. |
Bug report
What is the current behavior?
Webpack in some cases reports errors according to .js files instead of originating .ts files. For the repro below the error is
Line number of error is 8 instead of 13 as in startup.ts - line 8 is the corresponding number from the .js file if package would be compiled with typescript.
If there would be a typescript error, the correct line of the error will be output.
If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/jeffrson/webpack-ts-line-numbers.git
call
yarn
then
yarn webpack
finally check
yarn tsc
for comparing startup.jsWhat is the expected behavior?
should report line 13 and correct columns for file startup.ts
Other relevant information:
webpack version: 5.5.1
Node.js version: 14.15.1
Operating System: Windows 10
Additional tools:
The text was updated successfully, but these errors were encountered: