javascript - How to use source map to find minification error -
i work angular , requirejs. tried use requirejs optimization, , application not working. sure it's due minification.
uncaught error: [$injector:modulerr] http://errors.angularjs.org/1.2.0rc1/$injector/modulerr?p0=myapp&p1=error%3…t%20(http%3a%2f%2flocalhost%3a8080%2fwebapp%2fapp%2fmain-built.js%3a4%3a10)
the error message not helpful find issue, wondering how can use source map pinpoint error in original source code. use chrome debug.
edit: full error stacktrace
failed instantiate module myapp due to: error: [$injector:unpr] http://errors.angularjs.org/1.2.0rc1/$injector/unpr?p0=e @ error (<anonymous>) @ http://localhost:8080/webapp/app/main-built.js:3:19581 @ http://localhost:8080/webapp/app/main-built.js:3:31899 @ n (http://localhost:8080/webapp/app/main-built.js:3:30540) @ object.r [as invoke] (http://localhost:8080/webapp/app/main-built.js:3:30716) @ http://localhost:8080/webapp/app/main-built.js:3:30147 @ array.foreach (native) @ o (http://localhost:8080/webapp/app/main-built.js:3:19891) @ (http://localhost:8080/webapp/app/main-built.js:3:29951) @ yt (http://localhost:8080/webapp/app/main-built.js:4:10
here steps should make working you:
- in chrome's developer tools click settings icon (bottom right corner).
- in settings dialog, check "enable source maps".
- open web page want debug.
- open developer tools (in new tab)
- reload page
- it's important, otherwise chrome not download map file.
- press error link want inspect
- it's on right of error, i.e.
main.js:12
.
- it's on right of error, i.e.
- that's it. should redirected human-readable, non-minified version of script.
if source maps still not working:
make sure minified js file contains, @ bottom, like:
//# sourcemappingurl=main.js.map
make sure mapping file being downloaded. should listed in "network" section of developer tools downloaded during page reload. should this:
maybe requirejs's minification strips out
sourcemappingurl
comment output js file?make sure you're using
uglify2
method , you've enabledgeneratesourcemaps
option. here relevant part ofrequirejs
target config grunt:
requirejs: { compile: { options: { /* other options here */ optimize: 'uglify2', loglevel: 0, preservelicensecomments: false, generatesourcemaps: true } } }
Comments
Post a Comment