Last active
February 20, 2024 01:30
-
-
Save WanLinLin/066cdf9fd0fcc89fa8ad0d31813f6abd to your computer and use it in GitHub Desktop.
Find source position from minified stack trace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sourceMap = require("source-map"); | |
const fetch = require('node-fetch'); | |
const sourcemapUrl = 'https://example.com/9fb743af.chunk.js.map'; | |
const targetLine = 6; | |
const targetColumn = 9497; | |
fetch(sourcemapUrl) | |
.then(body => body.text()) | |
.then(map => new sourceMap.SourceMapConsumer(map)) | |
.then(consumer => { | |
console.log(consumer.originalPositionFor({ | |
line: targetLine, | |
column: targetColumn, | |
})); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment