From 5d71410915e6d4af6b4f6983bacc13468c174675 Mon Sep 17 00:00:00 2001 From: cenfun Date: Fri, 21 Jun 2024 22:32:45 +0800 Subject: [PATCH] fixed a sourcemap content issue --- CHANGELOG.md | 3 +++ lib/converter/collect-source-maps.js | 15 +++++++++++---- package.json | 2 +- test/package.json | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f314fdb..118e050b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Changelog +- 2.8.5 + - fixed a sourcemap content issue + - 2.8.4 - updated UI: highlight keywords for searching results - fixed coverage for static initialization blocks (#37) diff --git a/lib/converter/collect-source-maps.js b/lib/converter/collect-source-maps.js index e70f5146..06fc0927 100644 --- a/lib/converter/collect-source-maps.js +++ b/lib/converter/collect-source-maps.js @@ -63,9 +63,14 @@ const resolveSourcesContent = (data, url) => { const { sources, sourcesContent } = data; - let failed = false; + // sources [1,2,3] + // sourcesContent could be [null, null, "content"] + // some of contents could be missed + + let hasSourceContent = false; sources.forEach((file, i) => { if (typeof sourcesContent[i] === 'string') { + hasSourceContent = true; return; } @@ -79,16 +84,18 @@ const resolveSourcesContent = (data, url) => { const content = Util.readFileSync(path.resolve(sourcePath)); if (typeof content === 'string') { sourcesContent[i] = content; + hasSourceContent = true; return; } } - Util.logDebug(EC.red(`failed to load source content ${file}`)); - failed = true; + sourcesContent[i] = ''; + Util.logDebug(EC.red(`failed to load source content: ${file}`)); + }); - if (!failed) { + if (hasSourceContent) { return data; } }; diff --git a/package.json b/package.json index 893223e5..f4f9dfe7 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "stylelint": "^16.6.1", "stylelint-config-plus": "^1.1.2", "supports-color": "^9.4.0", - "tsx": "^4.15.6", + "tsx": "^4.15.7", "ws": "^8.17.1" } } diff --git a/test/package.json b/test/package.json index 97b97bca..64a1fc8a 100644 --- a/test/package.json +++ b/test/package.json @@ -19,7 +19,7 @@ "mocha": "^10.4.0", "open": "^10.1.0", "playwright": "^1.44.1", - "puppeteer": "^22.11.2", + "puppeteer": "^22.12.0", "rollup": "^4.18.0", "swc-loader": "^0.2.6", "ts-loader": "^9.5.1",