for await (const file of getAllFiles(path.join(__dirname, ".."))) { if (!file.endsWith(".js")) continue; if ( !(await fs .stat(file + ".map") .then(() => true) .catch(() => false)) ) continue; // make sure .map file exists const fileBuff = await fs.readFile(file + ".map"); if (URL && URL.createObjectURL) { // only run this stuff if we are running in a browser window const mappingsWasmBuffer = await fs.readFile( path.join(__dirname, "../../node_modules/source-map/lib/mappings.wasm") ); const mappingsWasmBlob = new Blob([mappingsWasmBuffer], { type: "application/wasm", }); // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore Typescript is missing this function... Probably because it is static sourceMapConsumer.initialize({ "lib/mappings.wasm": URL.createObjectURL(mappingsWasmBlob), }); } const sourceMapConsumer = await new SourceMapConsumer(fileBuff.toString()); sourceMaps.set(file, sourceMapConsumer); }