https://github.com/getsentry/rust-sourcemap
A library for rust that implements basic sourcemap handling
https://github.com/getsentry/rust-sourcemap
tag-production
Last synced: 5 months ago
JSON representation
A library for rust that implements basic sourcemap handling
- Host: GitHub
- URL: https://github.com/getsentry/rust-sourcemap
- Owner: getsentry
- License: other
- Created: 2016-06-05T15:32:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-04-23T11:30:17.000Z (6 months ago)
- Last Synced: 2025-04-23T12:29:23.681Z (6 months ago)
- Topics: tag-production
- Language: Rust
- Homepage:
- Size: 4.41 MB
- Stars: 234
- Watchers: 52
- Forks: 33
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# sourcemap
This library implements basic processing of JavaScript sourcemaps.
## Installation
The crate is called sourcemap and you can depend on it via cargo:
```toml
[dependencies]
sourcemap = "*"
```If you want to use the git version:
```toml
[dependencies.sourcemap]
git = "https://github.com/getsentry/rust-sourcemap.git"
```## Basic Operation
This crate can load JavaScript sourcemaps from JSON files. It uses
`serde` for parsing of the JSON data. Due to the nature of sourcemaps
the entirety of the file must be loaded into memory which can be quite
memory intensive.Usage:
```rust
use sourcemap::SourceMap;
let input: &[_] = b"{
\"version\":3,
\"sources\":[\"coolstuff.js\"],
\"names\":[\"x\",\"alert\"],
\"mappings\":\"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM\"
}";
let sm = SourceMap::from_reader(input).unwrap();
let token = sm.lookup_token(0, 0).unwrap(); // line-number and column
println!("token: {}", token);
```## Features
Functionality of the crate can be turned on and off by feature flags. This is the
current list of feature flags:* `ram_bundle`: turns on RAM bundle support
License: BSD-3-Clause