diff --git a/src/loader/webpack5-istanbul-loader.ts b/src/loader/webpack5-istanbul-loader.ts index 2d21da7..6410ffe 100644 --- a/src/loader/webpack5-istanbul-loader.ts +++ b/src/loader/webpack5-istanbul-loader.ts @@ -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