Skip to content

sleeuwen/sourcemaps

Repository files navigation

SourceMaps

.NET Standard 2.0 library for parsing and using SourceMaps

Packages

SourceMaps NuGet Version

SourceMaps library that handles parsing of the sourcemap and has methods for getting the original position, name and file for a generated position.

SourceMaps.StackTraces NuGet Version

SourceMaps.StackTraces is an additional package that can be used to parse JavaScript stack traces and map them with the source map to the original files.

Usage

SourceMaps

To parse a sourcemap

using SourceMaps;

var sourceMap = SourceMapParser.Parse(sourceMapAsString);

To get the original mapping for a given generated position, use

var mapping = sourceMap.OriginalPositionFor(generatedLineNumber: 1, generatedColumnNumber: 1);

mapping.OriginalName; // original token name
mapping.OriginalFileName; // original file name
mapping.OriginalSourcePosition.LineNumber; // original line number
mapping.OriginalSourcePosition.ColumnNumber; // original column number

SourceMaps.StackTraces

To get the original stack trace using the source maps

StackTraceParser.ReTrace(
    sourceMap,
    stackTrace: @"ReferenceError: ""getExceptionProps"" is undefined
    at eval code (eval code:1:1)
    at foo (http://path/to/file.js:58:17)
    at bar (http://path/to/file.js:109:1)",
    sourceRoot: "https://localhost:5001/js/");

About

.NET Standard library for parsing source maps

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages