Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
names: [],
mappings:
';;AAAA,IAAM,IAAI,SAAJ,CAAI,GAAM;AACZ,YAAQ,GAAR,CAAY,UAAK,GAAjB;AACH,CAFD;;;ACAA,IAAM,IAAI,SAAJ,CAAI,GAAM;AACZ,YAAQ,GAAR,CAAY,UAAK,GAAjB;AACH,CAFD',
file: 'bundle.js',
sourcesContent: [
'const b = () => {\n console.log(this.heh);\n};',
'const a = () => {\n console.log(this.lol);\n};',
],
};
const result = await minifyFromString(js, 'bundle.js', JSON.stringify(map));
expect(result.code).toMatchInlineSnapshot(`
"\\"use strict\\";var b=function(){console.log((void 0).heh)},a=function(){console.log((void 0).lol)};
//# sourceMappingURL=bundle.js.map"
`);
const consumer = await SourceMapConsumer.fromSourceMap(result.map);
// Verify the original code, from before babel, made it to the sourcemap
expect(consumer.sourceContentFor('file.js')).toMatchInlineSnapshot(`
"const b = () => {
console.log(this.heh);
};"
`);
consumer.destroy();
});
return sources.getSourceMap(source).then(prevMap => {
if (prevMap) {
// Compose the source maps
this._oldSourceMapping = {
url: source.sourceMapURL,
map: prevMap
};
prevMap = SourceMapGenerator.fromSourceMap(prevMap);
prevMap.applySourceMap(sm, this.url);
sm = SourceMapConsumer.fromSourceMap(prevMap);
}
let sources = this.threadActor.sources;
sources.clearSourceMapCache(source.sourceMapURL);
sources.setSourceMapHard(source, null, sm);
});
},
}).then(() => {
generator.setSourceContent(this.url, code);
let consumer = SourceMapConsumer.fromSourceMap(generator);
return {
code: code,
map: consumer
};
});
},