
Rust Sourcemap
https://github.com/getsentry/rust-sourcemap- Category
- Developer Tools
- Rank
- No. 891Tools index
- Pricing
- Open Source
- Type
- TOOL
- Builder
- getsentry
- GitHub
- 247 stars
- Latest release
- 9.3.2
- Date
About
Rust library for parsing and generating sourcemaps so you can map minified stack traces back to original source.
What it does
It ingests JavaScript source-map JSON, represents mappings as searchable tokens, and writes maps back to JSON. One decoding interface distinguishes regular maps, indexed maps, and Metro plus Hermes variants. It also detects map references embedded in JavaScript and handles base64 data URLs.
Why it's ranked here
The scope is unusually practical for a Rust crate: reading, writing, detection, map construction, indexed maps, Hermes metadata, range mappings, debug IDs, and optional RAM bundles share one library interface. The main reservation is explicit and important: each source-map file is loaded wholly into memory.
What's good
The decoder validates malformed mapping segments, missing source or name references, VLQ overflow, invalid base64, and incompatible formats with specific error variants. Builders can retain names and source contents, strip prefixes, mark ignored sources, preserve debug IDs, and construct range mappings. Tests cover encoding, decoding, overflow, paths, and metadata serialization.
Tradeoffs
Memory use can become expensive because parsing requires the complete map in memory. RAM bundle support adds an optional dependency and must be enabled explicitly. Local source-content loading is limited to Unix, Windows, and Redox targets. The repository presents a Rust library, not a ready-made command-line application or remote map retrieval service.
How to use it well
Use it inside Rust tooling that already obtains JavaScript bundles and source maps, then needs validated decoding, coordinate lookup, rewriting, or JSON output. It particularly suits React Native pipelines needing indexed maps, Hermes scope information, or optional RAM bundle handling. Pair it with separate code for network fetching, user-facing commands, and stack-trace orchestration.
Technical notes+
Cargo.toml defines the sourcemap Rust crate with edition 2018, Serde-based JSON dependencies, and the optional ram_bundle feature backed by scroll. src/lib.rs re-exports DecodedMap, SourceMap, SourceMapIndex, SourceMapHermes, SourceMapBuilder, decoding helpers, detection helpers, and VLQ utilities. src/decoder.rs strips junk headers, decodes regular, indexed, and Hermes representations, accepts base64 JSON data URLs, and validates range-mapping bitfields. src/encoder.rs serializes regular and indexed maps, including range mappings, ignore lists, and debug IDs. src/hermes.rs resolves enclosing function names from Metro scope metadata but retains the original Facebook metadata because parsed function-map mappings are not reconstructed during serialization. src/ram_bundle.rs implements indexed and file-based bundle parsing behind the optional feature. The Makefile runs tests both with default configuration and all features, plus rustfmt and Clippy checks.
Observed
- License
- BSD-3-Clause
- Primary language
- Rust
- Packaging
- Cargo crate named sourcemap, installable from the registry or Git repository
- Interface
- Rust library API
- Optional feature
- RAM bundle support is enabled through the ram_bundle Cargo feature
- Platform support
- Local source-content loading is compiled for Unix, Windows, and Redox
- Quality checks
- Make targets run Cargo tests with default and all features, rustfmt checks, and Clippy
Read from README.md, Makefile, Cargo.toml, src/lib.rs, src/vlq.rs, src/types.rs, src/utils.rs, src/errors.rs, src/hermes.rs, src/builder.rs, src/decoder.rs, src/encoder.rs, src/detector.rs, src/jsontypes.rs, src/ram_bundle.rs.
What it can do
Parse sourcemap files
Sourcemap file → Parsed sourcemap data structure
Generate sourcemap files
Source code mapping information → Sourcemap file
Map minified stack traces to original source
Minified stack trace and sourcemap → Original source location and context
Resolve original file names from minified references
Minified file reference and sourcemap → Original file name and path
Translate minified line and column numbers
Minified position coordinates and sourcemap → Original source line and column numbers
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.