How to use convert-source-map
Comprehensive convert-source-map code examples:
How to use convert-source-map.removeComments:
44 45 46 47 48 49 50 51 52 53
} if (opts.sourceMap) { inputMap = convertSourceMap.fromSource(body); if (inputMap) inputMap = inputMap.toObject(); body = convertSourceMap.removeComments(body); sourcemapper = new MagicString(body); } ast = acorn.parse(body, parserOpts);
How to use convert-source-map.fromBase64:
66 67 68 69 70 71 72 73 74 75
var lineOffset = 3 var base64 = combine.create() .addFile(file, { line: lineOffset }) .base64() var sm = convert.fromBase64(base64).toObject(); var res = checkMappings(foo, sm, lineOffset); t.ok(res.genLinesOffset, 'all generated lines are offset properly and columns unchanged') t.ok(res.origLinesSame, 'all original lines and columns are unchanged')
How to use convert-source-map.fromJSON:
GitHub: leechipang/grpc007
126 127 128 129 130 131 132 133 134 135 136 137
} } } if (map) { output += '\n' + convertSourceMap.fromJSON(map.toString()).toComment() } return { code: output } }
How to use convert-source-map.fromObject:
151 152 153 154 155 156 157 158 159 160
source: opts.inputFilename || 'input.js', includeContent: true }); if (inputMap) { var merged = mergeSourceMap(inputMap, map); output.write('\n' + convertSourceMap.fromObject(merged).toComment() + '\n'); } else { output.write('\n//# sourceMappingURL=' + map.toUrl() + '\n'); } }
How to use convert-source-map.fromSource:
46 47 48 49 50 51 52 53 54 55
const rawSource = this.sources.source || await readFile(this.path, 'utf8') this.rawSourceMap = this.sources.sourceMap || // if we find a source-map (either inline, or a .map file) we load // both the transpiled and original source, both of which are used during // the backflips we perform to remap absolute to relative positions. convertSourceMap.fromSource(rawSource) || convertSourceMap.fromMapFileSource(rawSource, dirname(this.path)) if (this.rawSourceMap) { if (this.rawSourceMap.sourcemap.sources.length > 1) { this.sourceMap = new TraceMap(this.rawSourceMap.sourcemap)