Skip to main content

Unpack JavaScript source maps into source files

Project description

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 -m py_unpack_sourcemap [-h] -o OUTPUT_DIR [--overwrite] 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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_unpack_sourcemap-1.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

py_unpack_sourcemap-1.0.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file py_unpack_sourcemap-1.0.1.tar.gz.

File metadata

  • Download URL: py_unpack_sourcemap-1.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.1.60-1-lts

File hashes

Hashes for py_unpack_sourcemap-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a99f8a4a160dd7235360eb8fdb4dcf490fe08daa9671415610a48fe89142ace4
MD5 c7b90b8180da3e2b711b81cba7dea377
BLAKE2b-256 38558a63aea6c9858c24e31255ec5c4ea1fc0bcb12090a399855ffe7eedc1125

See more details on using hashes here.

File details

Details for the file py_unpack_sourcemap-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_unpack_sourcemap-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 29b3f33a8f81a7669ee3741066414a369b08b887eaa2781780471e91b5f52090
MD5 63f4c4d3bdca630fc97b75748d3f3156
BLAKE2b-256 f55b0c370e8577e26793f09f3e461ee68b3c5dfa171687cfda318a23ebbad34c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page