Skip to content Skip to sidebar Skip to footer

How To Use Source Map To Find Minification Error

I work with Angular and RequireJS. I tried to use RequireJS optimization, and now my application is not working. I am sure it's due to minification. Uncaught Error: [$injector:modu

Solution 1:

Here are the steps which should make it working for you:

  1. In Chrome's Developer Tools click the settings icon (bottom right corner).
  2. In the settings dialog, check "Enable source maps".
  3. Open the web page you want to debug.
  4. Open the Developer Tools (in this new tab)
  5. Reload the page
    • It's important, otherwise Chrome will not download map file.
  6. Press the error link you want to inspect
    • It's on the right of your error, i.e. main.js:12.
  7. That's it. You should be now redirected to human-readable, non-minified version of your script.

If source maps are still not working:

  1. Make sure minified JS file contains, at the very bottom, something like:

    //# sourceMappingURL=main.js.map

  2. Make sure mapping file is being downloaded. It should be listed in "Network" section of Developer Tools as downloaded during page reload. It should look like this:

    source map file download status

  3. Maybe RequireJS's minification strips out the sourceMappingURL comment from your output JS file?

    Make sure that you're using uglify2 method and you've enabled generateSourceMaps option. Here is relevant part of my requirejs target config from Grunt:

requirejs: {
  compile: {
    options: {
      /*someotheroptionshere*/optimize:'uglify2',
      logLevel:0,
      preserveLicenseComments:false,
      generateSourceMaps:true
    }
  }
}

Post a Comment for "How To Use Source Map To Find Minification Error"