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:
- In Chrome's Developer Tools click the settings icon (bottom right corner).
- In the settings dialog, check "Enable source maps".
- Open the web page you want to debug.
- Open the Developer Tools (in this new tab)
- Reload the page
- It's important, otherwise Chrome will not download map file.
- Press the error link you want to inspect
- It's on the right of your error, i.e.
main.js:12.
- It's on the right of your error, i.e.
- That's it. You should be now redirected to human-readable, non-minified version of your script.
If source maps are still not working:
Make sure minified JS file contains, at the very bottom, something like:
//# sourceMappingURL=main.js.mapMake 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:

Maybe RequireJS's minification strips out the
sourceMappingURLcomment from your output JS file?Make sure that you're using
uglify2method and you've enabledgenerateSourceMapsoption. Here is relevant part of myrequirejstarget 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"