This package resolves JavaScript stack frame positions against a Source Map v3 file. It returns the original source file, line, column, symbol name, and enclosing scope. It is tuned for stack frame resolution (for example, symbolicating JavaScript errors using an uploaded source map), and is narrowly focused on the read path. It does not write, merge, or transform maps.
use Spatie\SourcemapsLookup\SourceMapLookup;
$map = SourceMapLookup::fromFile('bundle.js.map');
$position = $map->lookup(42, 17);
echo $position->sourceFileName;
echo $position->sourceLine;
echo $position->sourceColumn;
$scope = $map->scopeAt(42, 17);
echo $scope->name;
echo $scope->parent?->name;
Resolving 20 stack frames against a 6 MB production source map takes around 3.8 ms and uses about 18 MiB of memory on an Apple M1 Pro. See Benchmarks for the full picture.