Frage

I bundle all my JS assets into one minified uglified file via r.js (part of requirejs).

If any unhandled errors occur on the browser, I use raygun (like Airbrake) to report it back to me. The only problem is the line number I get in my error message, refers to the bundled minified file. Which doesn't help much.

Is there a way to correctly map the line number of my single minified and uglified bundled asset, into the individual JS file with the correct line number?

War es hilfreich?

Lösung

The first thing you need to do is have r.js generate a source map of the bundle. To do this, in the options you pass to r.js you need to have the option generateSourceMaps set to true and you must set the optimize option to "uglify2" or

"closure" with a closure compiler jar build after r1592 (20111114 release)."

(I'm citing from this documentation.) I've done it with optimize set to "uglify2" and was able to get decent references to the original source code in Chrome.

The logging service must also support it. This post over at the raygun forums suggests that raygun does not yet support source maps.

Someone created a list of such services as a gist over at github. Some of the services are marked as supporting source maps. I can't vouch for its accuracy but it could be a good starting point to find a service that supports it.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top