I try to implement a small custom logger in our JavaScript project that contains multiple source files. It is minified, but during the development with a full source map. (Webpack: devtool: "inline-source-map")
If I log an error object to the console then I can see the real line numbers. However, if I want to process it and use Error.stack then I get the line numbers from the minified code that is almost useless.
This is my example code:
const err = new Error();
const stack = err.stack;
console.log('Error: ', err);
console.log('Error: ', stack);
And the output:
Error: Error
at log (background.ts:18)
at background.ts:29
at eventService.ts:170
at util.ts:124
...
Error: Error
at log (chrome-extension://hkikkdnnkfiomhblbgonboibnjgkjocp/background.js:735:17)
at chrome-extension://hkikkdnnkfiomhblbgonboibnjgkjocp/background.js:746:1
at chrome-extension://hkikkdnnkfiomhblbgonboibnjgkjocp/background.js:889:3
at chrome-extension://hkikkdnnkfiomhblbgonboibnjgkjocp/background.js:891:12
...
Is there a way to get the real source in case of a minified code? Can I get the first error output in a processable manner?