Modern JavaScript build tools compile entire folder structures of JavaScript code into single, minified files that are near-impossible to read, but can also include source maps which can be used to display the original code in tools such as the Chrome DevTools Sources panel.
These source maps can be processed to extract mainly meaningful code and file structures, by installing a package and running a simple bash command.
Generally, production builds shouldn't include source maps, but if you do manage to lose your source files, or for some (obviously, ethical!) reason need to view the original files, and you happen to have / find the source maps, you're good to go.
This code will work on Mac/Unix.
- Locate your compiled files, which should include
*.js.map
files - Create a new folder
<project>
- Place files in
<project>/input
- Run the script below from
<project>
- View the files
The script installs a module from a PR to the main Shuji repository.
It may be that by the time you read this, that PR has been merged, so the module install will fail.
If so, update the install line with the main repository:
npm install paazmaya/shuji
Only the information in the source maps can be restored.
If these don't contain the full source code, then you're out of luck. Work with what you have!