webpack: Wrong line numbers when processing files after ts-loader

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

ERROR in ./startup.ts 8:11-31
Module not found: Error: Can't resolve 'some_file' in 'C:\src\webpack-5\test'

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.js

What 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:

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 19 (7 by maintainers)

Most upvoted comments

The first solution looks good, but let’s it do only for errored modules

I think we should do it after loader processing