Skip to content

Instantly share code, notes, and snippets.

@benvinegar
Last active February 24, 2017 21:18
Show Gist options
  • Save benvinegar/0a1a275ba9b5805ea4c434e6f64639c3 to your computer and use it in GitHub Desktop.
Save benvinegar/0a1a275ba9b5805ea4c434e6f64639c3 to your computer and use it in GitHub Desktop.
Verify your source map mappings locally
/* npm install -g source-map */
var fs = require('fs');
var sourceMap = require('source-map');
var rawSourceMap = fs.readFileSync('./app.js.map').toString();
var smc = new sourceMap.SourceMapConsumer(rawSourceMap);
// output original filename, line, column, token for input {line, column}
// in built/minified file (e.g. app.min.js)
// see: https://github.com/mozilla/source-map#sourcemapconsumerprototypeoriginalpositionforgeneratedposition
var pos = smc.originalPositionFor({ line: 1337, column: 1337});
// should see something like:
// { source: 'original.js', line: 1, column: 9, name: 'test' }
console.log(pos);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment