Revert JavaScript mini-setting using source map

Is it possible to get the correct JavaScript source file if I have a mini file and its corresponding source map?

I know how to pre-refine JS code (line breaks and indentations), but I would like to get the original function / variable names in the file in order to better understand the source code.

I would like to get the Unminified JS file to work instead of using it to debug in the browser.

PS It's probably somewhere right under my nose, but haven't been able to find it yet. Sorry if this has already been asked!

+3


source to share


2 answers


Working with source files requires both minified and original files, often the originals included in the sourcemap file (it has optional content sources for sources that cannot be hosted).

Sourcemap is just a JSON file and you can find all the information you need inside:



  • sources - list of names of source files,
  • sourcesContent - optional list from source sources, if no source is provided it will be null here.

A utility script, I already wrote for this purpose: https://gist.github.com/zxbodya/ca6fb758259f6a077de7

+3


source


I think that you cannot completely revert such code to its original state, since most of the information (for example, comments or specific variable names) is simply lost in the process. When I understand the source files correctly for this, you still need the original file.

If your only goal is to pre-dictate the code so that it can be read again, you don't need source maps. Many modern editors have these features. For example, if you are using Sublime Text, there is this plugin: https://packagecontrol.io/packages/HTML-CSS-JS%20Prettify which does a great job.



Also see a similar question: How to debug mini JS in firebug?

0


source







All Articles