Skip to content

lonelyteapot/py_unpack_sourcemap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py_unpack_sourcemap

Unpack JavaScript source maps into source files

PyPI - Version PyPI - Downloads PyPI - Status License

Description

This Python tool allows you to extract JavaScript source files from source maps. It can be particularly useful for debugging and analyzing minified JavaScript code in production environments.

Modern browsers like Chrome and Firefox provide this functionality in DevTools. However, they only let you view the source code in the browser itself, which can be limiting. This tool allows you to extract the whole source tree for viewing it in your favourite IDE.

This projects aims to follow the Source Map Revision 3 Proposal. Only the sourcesContent field is currently supported. See Roadmap for what is lacking.

Installation

Ensure you have Python 3.10 or later installed. The package is not tested on older versions, but they will probably work.

You can install the tool from PyPI using pip:

pip install py_unpack_sourcemap

Or Poetry:

poetry add py_unpack_sourcemap

Usage

As a command-line tool

python py_unpack_sourcemap [-h] -o OUTPUT_DIR [--overwrite] [--ignore-source-root] sourcemap

positional arguments:
  sourcemap             path to the source map (a .js.map file)

options:
  -h, --help            show this help message and exit
  -o OUTPUT_DIR, --output-dir OUTPUT_DIR
                        a directory to extract source files into
  --overwrite           overwrite existing output directory
  --ignore-source-root  ignore the 'sourceRoot' field, put files directly in the directory

As a Python module

No information here yet :( Use autocompletion or view the source code.

Roadmap

This project is developed on demand. If you need a feature, submit an issue to express your interest.

  • Support for fetching remote source maps via HTTP
  • Support for null elements in sourcesContent field
  • More tests
  • Support for sourceRoot field
  • Support for names field
  • Support for mappings field
  • "Index map" format (sections field)
  • GitHub workflows for tests and publishing

Contributing

Any contributions are appreciated. Regular stuff. Don't be afraid to submit issues or PRs.

Contributors

License

This project is licensed under the MIT License.

About

Unpack JavaScript source maps into source files

Topics

Resources

License

Stars

Watchers

Forks