Stack overflow has a great answer to this question that can be found at: https://stackoverflow.com/questions/21719562/how-to-use-javascript-source-maps-map-files
Please read the original source for more info as it is copied here for convenience only.
The .map
files are for js
and css
(and now ts
too) files that have been minified. They are called SourceMaps. When you minify a file, like the angular.js file, it takes thousands of lines of pretty code and turns it into only a few lines of ugly code. Hopefully, when you are shipping your code to production, you are using the minified code instead of the full, unminified version. When your app is in production, and has an error, the sourcemap will help take your ugly file, and will allow you to see the original version of the code. If you didn’t have the sourcemap, then any error would seem cryptic at best.
So, to answer you questions in order:
- What is it for? To de-reference uglified code
- How can a developer use it? You use it for debugging a production app. In development mode you can use the full version of Angular. In production, you would use the minified version.
- Should I care about creating a js.map file? If you care about being able to debug production code easier, then yes, you should do it.
- How does it get created? It is created at build time. There are build tools that can build your .map file for you as it does other files. https://github.com/gruntjs/grunt-contrib-uglify/issues/71