I've got problem debugging minified JS on production server.
While you can't catch some errors on your machine while testing dev/prod
servers, there's an opportunity to send some frontend errors and exceptions from users to a special log.
When JS files are minified, debugging this code becomes a hell.
What are the best practices in performing such work?
Javascript files can be debugged in Chrome Browser the same way you debug HTML/CSS files i.e using Chrome Developer Tools which can be launched via following shortcuts as per the OS you use.
You can debug JavaScript and TypeScript code using Visual Studio. You can hit breakpoints, attach the debugger, inspect variables, view the call stack, and use other debugging features.
Biting the bullet ;) In chrome you can auto format the minified code from the sources panel
Then you can add debugger statements by clicking the line numbers. Run your code and find out more...
So, after some time, we've continued to try and resolve damn trouble and we've stumbled upon this library that allows you to map your stack to unminified version of build.
https://github.com/mozilla/source-map
We needed this to embed to our internal system that collects error reports. There are also ready solutions across the web if don't need your own like we do:
https://raygun.com/sourcemaps
https://sourcemaps.info/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With