An open API service indexing awesome lists of open source software.

https://github.com/leegeunhyeok/sourcemap-explorer

🗺️ Rust based sourcemap explorer for command-line interface
https://github.com/leegeunhyeok/sourcemap-explorer

Last synced: 24 days ago
JSON representation

🗺️ Rust based sourcemap explorer for command-line interface

Awesome Lists containing this project

README

        

# sourcemap-explorer

Rust based sourcemap explorer for command-line interface.

## Features

- ⚡️ Light-weight & blazing fast
- 🗺️ Easy to reverse sourcemap mapping
- 🌱 Print original source content

## Installation

```bash
# Homebrew
brew tap leegeunhyeok/tap
brew install sourcemap-explorer

# Other platforms: TBD
```

## Usage

```bash
# Defualt
smx ./fixtures/bundle.js.map 5:19 --content

# Hermes
smx ./fixtures/bundle.hbc.map 1:95 \
--type hermes \
--hermes-packager-sourcemap ./fixtures/bundle.js.map \
--content
```

```
Sourcemap explorer

Usage: smx [OPTIONS]

Arguments:
Sourcemap file path
Position of the source code (eg. 1:549)

Options:
--type
Type of runtime [default: default] [possible values: default, hermes]
--hermes-packager-sourcemap
If you use Hermes runtime (--type hermes),
you need to provide the sourcemap file path of the packager (eg. Metro)
--content
Print the original source content
--json
Print the result in JSON format
-h, --help
Print help
-V, --version
Print version
```

![preview](image.png)

Hermes

> This section is a guide to lookup packager sourcemap from Hermes bytecode sourcemap manually.

```bash
./hermesc ./fixtures/bundle.hbc
```

```
Hello, world!
Uncaught Error: Boom!
at anonymous (address at ./fixtures/bundle.hbc:1:95)
at global (address at ./fixtures/bundle.hbc:1:9)
```

```bash
smx ./fixtures/bundle.hbc.map 1:95

# File - ./fixtures/bundle.js
# Position - :5:19
```

```js
// `:5:19` in bundle.js
throw new Error('Boom!');
```

And you can find the original source code from `index.js`

```bash
smx ./fixtures/bundle.js.map 5:19 --content
```

![preview](hbc-lookup.png)

## Development

```bash
# Run with fixtures
cargo run -- ./fixtures/bundle.js.map 1:549 --content

# build
./scripts/build.sh
```

## License

[BSD 3-Clause](./LICENSE)