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:

  1. in chrome's developer tools click settings icon (bottom right corner).
  2. in settings dialog, check "enable source maps".
  3. open web page want debug.
  4. open developer tools (in new tab)
  5. reload page
    • it's important, otherwise chrome not download map file.
  6. press error link want inspect
    • it's on right of error, i.e. main.js:12.
  7. that's it. should redirected human-readable, non-minified version of script.

if source maps still not working:

  1. make sure minified js file contains, @ bottom, like:

    //# sourcemappingurl=main.js.map

  2. make sure mapping file being downloaded. should listed in "network" section of developer tools downloaded during page reload. should this:

    source map file download status

  3. maybe requirejs's minification strips out sourcemappingurl comment output js file?

    make sure you're using uglify2 method , you've enabled generatesourcemaps option. here relevant part of requirejs target config grunt:

requirejs: {   compile: {     options: {       /* other options here */       optimize: 'uglify2',       loglevel: 0,       preservelicensecomments: false,       generatesourcemaps: true     }   } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -