How to use the fromObject function from convert-source-map

Find comprehensive JavaScript convert-source-map.fromObject code examples handpicked from public code repositorys.

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');
    }
}
fork icon0
star icon0
watch icon1

54
55
56
57
58
59
60
61
62
63
64
65
  mappings       :  ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',
  sourcesContent :  [ 'console.log(require \'./bar.js\')\n' ] };


test('add one file with inlined source', function (t) {


  var mapComment = convert.fromObject(foo).toComment();
  var file = {
      id: 'xyz'
    , source: '(function() {\n\n  console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + mapComment
    , sourceFile: 'foo.js'
fork icon0
star icon0
watch icon1

+ 15 other calls in file

99
100
101
102
103
104
105
106
107
108
})();
`;
    let line = getLineCounts(jsGlobals.script) + 2;
    const combinedSourceMap = combine.create("bundle.js");
    for (const file of results.files) {
        const comment = convert.fromObject(results.sourceMaps[file.name]).toComment();
        combinedSourceMap.addFile({ sourceFile: `/${player.gameName}/${file.name}`, source: file.text + `\n${comment}` }, { line });
        line += getLineCounts(file.text);
    }
    const code = `${jsGlobals.script}${results.script}
fork icon0
star icon0
watch icon0