Skip to content

Instantly share code, notes, and snippets.

@hi-ogawa
Last active October 17, 2024 09:06
Show Gist options
  • Save hi-ogawa/411f2ad04d7701d1391974d22b217502 to your computer and use it in GitHub Desktop.
Save hi-ogawa/411f2ad04d7701d1391974d22b217502 to your computer and use it in GitHub Desktop.
generate a link to evanw's source-map-visualization
// https://github.com/oxc-project/oxc/blob/a6487482bc053797f7f1a42f5793fafbd9a47114/crates/oxc_codegen/examples/sourcemap.rs#L34-L44
function generate(code, mapJson) {
const hashRaw = `${code.length}\0${code}${mapJson.length}\0${mapJson}`;
// const hash = btoa(hashRaw);
const hash = Buffer.from(hashRaw, "utf-8").toString("base64");
return `https://evanw.github.io/source-map-visualization/#` + hash;
}
console.log(generate(result.code, JSON.stringify(result.map)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment