Skip to content

Instantly share code, notes, and snippets.

@int3
Created June 12, 2013 21:18
Show Gist options
  • Save int3/5769221 to your computer and use it in GitHub Desktop.
Save int3/5769221 to your computer and use it in GitHub Desktop.
<html>
<body>
<script type="text/javascript" charset="utf-8" src='foo.js'></script>
</body>
</html>
"nothing here";
//@ sourceMappingURL=foo.js.map
{"version":3,"file":"foo.js","sources":["/a"],"names":[],"mappings":"AACA","sourcesContent":["foo"]}
var SourceMapGenerator = require('source-map').SourceMapGenerator;
var originalFileName = '/a';
// var originalFileName = 'a'; // this works
var generator = new SourceMapGenerator({ file: 'foo.js' });
generator.addMapping({
generated: { line: 1, column: 0 },
original: { line: 2, column: 0 },
source: originalFileName
});
generator.setSourceContent(originalFileName, 'foo');
console.log(generator.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment