Skip to content

Commit

Permalink
fixed a sourcemap content issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Jun 21, 2024
1 parent 9915d0e commit 5d71410
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
15 changes: 11 additions & 4 deletions lib/converter/collect-source-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5d71410

Please sign in to comment.