How to use the SourceNode function from source-map
Find comprehensive JavaScript source-map.SourceNode code examples handpicked from public code repositorys.
GitHub: PoeticMediaLab/annotator
10 11 12 13 14 15 16 17 18 19
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. // It cannot map our license preamble or the browserify wrappers.
547
3
3
54 55 56 57 58 59 60 61 62
logger(message, 'info'); } const node = new SourceNode(null, null, null, [ new SourceNode(null, null, this.resourcePath, prependText), SourceNode.fromStringWithSourceMap(processedSource, new SourceMapConsumer(map)) ]).join(separator); const result = node.toStringWithSourceMap();
16
33
3
+ 17 other calls in file
GitHub: gaearon/react-hot-loader
70 71 72 73 74 75 76 77 78 79
const sourceMapConsumer = new SourceMapConsumer(map); const onSourceMapReady = consumedMap => { const node = new SourceNode(null, null, null, [ SourceNode.fromStringWithSourceMap(source, consumedMap), new SourceNode(null, null, resourcePath, appendText), ]).join(separator); const result = node.toStringWithSourceMap(); callback(null, result.code, result.map.toJSON() || undefined); };
837
0
0
+ 3 other calls in file
GitHub: brunch/brunch
10 11 12 13 14 15 16 17 18 19
const identityNode = (code, path) => { const lines = code.split('\n').map((line, index) => { return new SourceNode(index + 1, 0, path, `${line}\n`); }); return new SourceNode(1, 0, null, lines); }; const prepSourceMap = (code, sourceMap) => { const consumer = new SourceMapConsumer(typeof sourceMap === 'string' ?
474
0
135
+ 27 other calls in file
67 68 69 70 71 72 73 74 75
// https://github.com/mozilla/source-map#sourcenode // https://github.com/webpack/imports-loader/blob/master/index.js#L34-L44 // https://webpack.github.io/docs/loaders.html#writing-a-loader if (sourceMap) { var currentRequest = loaderUtils.getCurrentRequest(this); var SourceNode = SourceMap.SourceNode; var SourceMapConsumer = SourceMap.SourceMapConsumer; var sourceMapConsumer = new SourceMapConsumer(sourceMap); var node = SourceNode.fromStringWithSourceMap(source, sourceMapConsumer);
16
87
0
21 22 23 24 25 26 27 28 29
scriptSetupResult, templateResult, filename, stylesResult ) { var node = new SourceNode(null, null, null) addToSourceMap(node, scriptResult) addToSourceMap(node, scriptSetupResult) addToSourceMap(node, templateResult)
2
0
0
GitHub: nivoc/meteor
136 137 138 139 140 141 142 143 144 145
sourceWidth: sourceWidth, noLineNumbers: self.noLineNumbers })); }); var node = new sourcemap.SourceNode(null, null, null, chunks); var results = node.toStringWithSourceMap({ file: self.combinedServePath }); // results has 'code' and 'map' attributes
0
2
2
+ 4 other calls in file
7 8 9 10 11 12 13 14 15 16
const Handlebars = require('handlebars/dist/cjs/handlebars.js'); const {SourceMapConsumer, SourceNode} = require('source-map'); exports.process = (code, filename) => { const pc = Handlebars.precompile(code, {srcName: filename}); const out = new SourceNode(null, null, null, [ 'const Handlebars = require("handlebars/dist/cjs/handlebars.runtime.js");\n', 'module.exports = Handlebars.template(', SourceNode.fromStringWithSourceMap(pc.code, new SourceMapConsumer(pc.map)), ');\n',
0
0
2
+ 5 other calls in file
GitHub: mcamac/tarp
82 83 84 85 86 87 88 89 90 91
if (transformedModule.map) { return SourceNode.fromStringWithSourceMap( codeWithTarpRequires, new SourceMapConsumer(transformedModule.map)); } else { var sn = new SourceNode(null, null, depModule.path); codeWithTarpRequires.split('\n') .forEach((line, i) => sn.add(new SourceNode(i + 1, 0, depModule.path, line + '\n'))); sn.setSourceContent(depModule.path, depModule.code); return sn;
0
0
2
+ 39 other calls in file
128 129 130 131 132 133 134 135 136 137
var pkg = fis.file(root, filepath); var has = []; var sourceNode; if (sourceMap) { sourceNode = new SourceMap.SourceNode(); } var content = ''; unpacked.forEach(function(item) {
0
0
2
+ 3 other calls in file
source-map.SourceMapConsumer is the most popular function in source-map (130 examples)