13

I am working on a project where I have to statically analyse JavaScript code. However, for a few libraries, I only have access to a minified version of the file and the corresponding source-map. Is there a method/technique with which I can generate the original file using these files?

Sid
  • 331
  • 3
  • 10

3 Answers3

10

I found a node.js library that can help do this: Maximize Corresponding github repo

Sid
  • 331
  • 3
  • 10
  • have you use it? If so did you find any traps for new players? – otherDewi Nov 22 '13 at 22:02
  • It works well. Although, it expects the input as a URL. You would have to make changes to input a file. – Sid Dec 05 '13 at 00:49
  • 4
    I **don't know Node JS** but I rewrote Maximize to work with local files (and actually work at all). Maybe someone who knows node-js would like to make this not horrible: https://github.com/timmc/unsourcemap – Tim has moved to Codidact Jan 21 '17 at 06:53
5

If your objective is "just" to do a onetime re-construction of the original source code I did it using:

Online Source Visualization

  1. use the "Custom" option
  2. upload compiled file
  3. upload source map file

Depending on filesize it may take a while to view the results.

The correspoding Repo is here

Core Tek
  • 101
  • 2
  • 6
1

This command line tool is really easy to use

npx uglify-js ugly.js -b --source-map "filename='ugly.js.map'" -o beauty.js

https://www.npmjs.com/package/uglify-js

https://stackoverflow.com/a/70584632/13581139

James Baird
  • 97
  • 1
  • 9