Skip to content

Instantly share code, notes, and snippets.

@WanLinLin
Last active February 20, 2024 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WanLinLin/066cdf9fd0fcc89fa8ad0d31813f6abd to your computer and use it in GitHub Desktop.
Save WanLinLin/066cdf9fd0fcc89fa8ad0d31813f6abd to your computer and use it in GitHub Desktop.
Find source position from minified stack trace
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