Skip to content

Instantly share code, notes, and snippets.

@raymond-w-ko
Created March 25, 2022 07:03
Show Gist options
  • Save raymond-w-ko/fea13a99975af5796e782699209d3b64 to your computer and use it in GitHub Desktop.
Save raymond-w-ko/fea13a99975af5796e782699209d3b64 to your computer and use it in GitHub Desktop.
const FS = require("fs")
const assert = require("assert")
const origSourceMap = JSON.parse(FS.readFileSync("./orig/index.js.map"))
const sections = origSourceMap.sections
assert.equal(sections.length, 1)
const sm = sections[0].map
const lineStart = sections[0].offset.line
const prefix = ";".repeat(lineStart)
sm.mappings = prefix + sm.mappings
FS.writeFileSync("index.js.map", JSON.stringify(sm))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment