From b5458e63c926427a6be0e9c57d5574c406b6a1b0 Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Wed, 12 Nov 2025 15:28:20 +0100 Subject: [PATCH 1/2] Build sourceMappingURL constructs with relative paths Signed-off-by: Joshua Rogers --- scripts/build.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 9fbad060a..730c29ab1 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -103,14 +103,28 @@ function buildFile(file, silent) { } (copy)\n`, ); } else { - const options = Object.assign({}, transformOptions); + const options = { + ...transformOptions, + sourceMaps: true, + sourceFileName: path.basename(file), + }; let {code, map} = babel.transformFileSync(file, options); - if (!file.endsWith('.d.ts') && map.sources.length > 0) { - code = `${code}\n\n//# sourceMappingURL=${destPath}.map`; - map.sources = [path.relative(path.dirname(destPath), file)]; - fs.writeFileSync(`${destPath}.map`, JSON.stringify(map)); + if (!file.endsWith('.d.ts')) { + const outDir = path.dirname(destPath); + const outFile = path.basename(destPath); + const mapFileName = `${outFile}.map`; + const mapPath = path.join(outDir, mapFileName); + + // Normalize/override key fields for consistency + map.file = outFile; + map.sources = [ + path.relative(outDir, file).replace(/\\/g, '/'), + ]; + + code = `${code}\n\n//# sourceMappingURL=${mapFileName}`; + fs.writeFileSync(mapPath, JSON.stringify(map)); } fs.writeFileSync(destPath, code); From 811cb874032920dfe1f8fec83aa1cc284dfa8b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 12 Nov 2025 20:10:03 +0100 Subject: [PATCH 2/2] prettier --- scripts/build.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 730c29ab1..905976f87 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -119,9 +119,7 @@ function buildFile(file, silent) { // Normalize/override key fields for consistency map.file = outFile; - map.sources = [ - path.relative(outDir, file).replace(/\\/g, '/'), - ]; + map.sources = [path.relative(outDir, file).replace(/\\/g, '/')]; code = `${code}\n\n//# sourceMappingURL=${mapFileName}`; fs.writeFileSync(mapPath, JSON.stringify(map));