Skip to content

Commit

Permalink
fix: ensure jest is always passed a sourceMap object
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Oct 18, 2023
1 parent 1908b1d commit 2f7c08f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/transform/create-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default ({ browser }: { browser: boolean }) => {
let { code, map } = result;

if (deps && deps.length) {
const concatMap = new ConcatMap(true, "", ";");
const concatMap = new ConcatMap(true, filename, ";");
const acceptPathReg = new RegExp(
`^(?:[./]*[^:.]*|[^:]+(?:${config.transform
.map(([reg], i) => `(?<_${i}>${reg})`)
Expand Down Expand Up @@ -129,7 +129,7 @@ export default ({ browser }: { browser: boolean }) => {

if (typeof transformResult === "object") {
depCode = transformResult.code;
depMap = depMap
depMap = depMap && transformResult.map
? mergeMaps(depMap, transformResult.map)
: undefined;
} else {
Expand All @@ -154,10 +154,10 @@ export default ({ browser }: { browser: boolean }) => {
}

code = concatMap.content.toString("utf-8");
map = concatMap.sourceMap;
map = (concatMap as any)._sourceMap?.toJSON?.() || JSON.parse(concatMap.sourceMap || "null");
}

return { code, map: map && JSON.stringify(map) };
return { code, map };
},
};

Expand Down

0 comments on commit 2f7c08f

Please sign in to comment.