You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
936 B

// Replace paths unavailable during compilation with `null`, so they will not be shown in devtools
;
(() => {
const fs = require("fs");
const path = require("path");
const outDir = __dirname + "/kotlin/"
const projecName = path.basename(__dirname);
const mapFile = outDir + projecName + ".map"
const sourcemap = JSON.parse(fs.readFileSync(mapFile))
const sources = sourcemap["sources"]
srcLoop: for (let i in sources) {
const srcFilePath = sources[i];
if (srcFilePath == null) continue;
const srcFileCandidates = [
outDir + srcFilePath,
outDir + srcFilePath.substring("../".length),
outDir + "../" + srcFilePath,
];
for (let srcFile of srcFileCandidates) {
if (fs.existsSync(srcFile)) continue srcLoop;
}
sources[i] = null;
}
fs.writeFileSync(mapFile, JSON.stringify(sourcemap));
})();