Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/sxzz/unloader. Node.js loader with a Rollup-like interface.
Something went wrong. Try again.
12345678910111213141516import { Buffer } from 'node:buffer'import type { SourceMap } from '@jridgewell/remapping'
export function attachSourceMap(map: SourceMap, code: string): string { if (map) { if (!map.sourcesContent || map.sourcesContent.length === 0) map.sourcesContent = [code] code += `\n//# sourceMappingURL=${toUrl(map)}` } return code}
function toUrl(map: SourceMap) { return `data:application/json;charset=utf-8;base64,${Buffer.from(map.toString()).toString('base64')}`}