How to use the SourceMapGenerator function from source-map
Find comprehensive JavaScript source-map.SourceMapGenerator code examples handpicked from public code repositorys.
GitHub: PoeticMediaLab/annotator
9 10 11 12 13 14 15 16 17 18
var through = require('through'); var UglifyJS = require('uglify-js'); var UglifyCSS = require('uglifycss'); var SourceMapConsumer = sourceMap.SourceMapConsumer; var SourceMapGenerator = sourceMap.SourceMapGenerator; var SourceNode = sourceMap.SourceNode; // Uglify emits ugly warnings for source maps it can't resolve.
547
3
3
GitHub: Macil/browserify-hmr
26 27 28 29 30 31 32 33 34 35
var validUpdateModes = ['websocket', 'ajax', 'fs', 'none']; var updateModesNeedingUrl = ['ajax']; function makeIdentitySourceMap(content, resourcePath) { var map = new sm.SourceMapGenerator(); map.setSourceContent(resourcePath, content); content.split('\n').map(function(line, index) { map.addMapping({ source: resourcePath,
26
375
9
0 1 2 3 4 5 6 7 8
'use strict' const sourceMap = require('source-map') const SourceNode = sourceMap.SourceNode const SourceMapConsumer = sourceMap.SourceMapConsumer const SourceMapGenerator = sourceMap.SourceMapGenerator module.exports = function(compiler, source, resourcePath, rawResult, generatedSource) { let rawMap = JSON.parse(compiler.$source_map())
10
17
4
GitHub: roytam1/UXP
201 202 203 204 205 206 207 208 209 210 211 212
"text/plain" }; } function applySourceMap(generatedId, url, code, mappings) { const generator = new SourceMapGenerator({ file: url }); mappings.forEach(mapping => generator.addMapping(mapping)); generator.setSourceContent(url, code); const map = SourceMapConsumer(generator.toJSON());
5
32
0
4 5 6 7 8 9 10 11 12 13 14
* @param {string} source The content of the source file. * @param {string} resourcePath The name of the source file. * @returns {import('source-map').RawSourceMap} The identity source map. */ function getIdentitySourceMap(source, resourcePath) { const sourceMap = new SourceMapGenerator(); sourceMap.setSourceContent(resourcePath, source); source.split('\n').forEach((line, index) => { sourceMap.addMapping({
0
0
0
2333 2334 2335 2336 2337 2338 2339 2340 2341 2342
} }); } if (sourceMap$1) { // lazy require source-map implementation, only in non-browser builds context.map = new sourceMap.SourceMapGenerator(); context.map.setSourceContent(filename, context.source); } return context; }
0
0
0
177 178 179 180 181 182 183 184 185 186
var mapping = fis.file.wrap(pkg.dirname + '/' + pkg.filename + pkg.rExt + '.map'); var code_map = sourceNode.toStringWithSourceMap({ file: pkg.subpath }); var generater = SourceMap.SourceMapGenerator.fromSourceMap(new SourceMap.SourceMapConsumer(code_map.map.toJSON())); mapping.setContent(generater.toString()); ret.pkg[mapping.subpath] = mapping; content += '//# sourceMappingURL=' + mapping.getUrl(); }
0
0
2
+ 3 other calls in file
source-map.SourceMapConsumer is the most popular function in source-map (130 examples)