Crate sourcemap

source ·
Expand description

This library implements basic processing of JavaScript sourcemaps.


The crate is called sourcemap and you can depend on it via cargo:

sourcemap = "*"

If you want to use the git version:

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.


use sourcemap::SourceMap;
let input: &[_] = b"{
let sm = SourceMap::from_reader(input).unwrap();
let token = sm.lookup_token(0, 0).unwrap(); // line-number and column
println!("token: {}", token);


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


  • Implements utilities for dealing with the sourcemap vlq encoding.



  • Represents the result of a decode operation
  • Represents different failure cases
  • Represents a reference to a sourcemap


Type Aliases

  • Represents results from this library