Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private generateSourceMap(bundle: MagicStringBundle | MagicString, href: string) {
const inputMap = bundle.generateMap({
includeContent: true,
hires: false,
source: href,
});
// In case a source map seems to be self-referential, avoid crashing
const seen = new Set();
return new SourceMap(
remapping(
inputMap.toString(),
(uri: string) => {
const asset = this.assetsByHref.get(uri);
if (asset && asset.sourceMappingUrl) {
if (seen.has(asset)) {
return null;
}
seen.add(asset);
const match = asset.sourceMappingUrl.match(/^data:application\/json;(?:charset=([^;]+);)?base64,(.*)$/);
if (match) {
if (match[1] && match[1] !== 'utf-8') {
return null;