Skip to content

Commit

Permalink
fix: πŸ› Fixed the problem that rawSourceMap may be a string
Browse files Browse the repository at this point in the history
Fixed the problem that rawSourceMap may be a string, causing the
coverage plug-in to report an error

βœ… Closes: #32
  • Loading branch information
hkaikai committed Dec 1, 2023
1 parent aacb3fb commit 280f528
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/loader/webpack5-istanbul-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type RawSourceMap = {
names?: string[];
};

function sanitizeSourceMap(rawSourceMap: RawSourceMap): RawSourceMap {
function sanitizeSourceMap(rawSourceMap: RawSourceMap | string): RawSourceMap {
if (typeof rawSourceMap === 'string') return JSON.parse(rawSourceMap);
const { sourcesContent, ...sourceMap } = rawSourceMap ?? {};

// JSON parse/stringify trick required for istanbul to accept the SourceMap
Expand Down

0 comments on commit 280f528

Please sign in to comment.