Skip to content

Commit

Permalink
Fix merging sourcemaps on Windows (#14282)
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Feb 17, 2022
1 parent 5c2fcad commit ea1c44e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/babel-core/src/transformation/file/merge-map.ts
Expand Up @@ -4,8 +4,16 @@ import remapping from "@ampproject/remapping";
export default function mergeSourceMap(
inputMap: SourceMap,
map: SourceMap,
source: string,
sourceFileName: string,
): SourceMap {
// On win32 machines, the sourceFileName uses backslash paths like
// `C:\foo\bar.js`. But sourcemaps are always posix paths, so we need to
// normalize to regular slashes before we can merge (else we won't find the
// source associated with our input map).
// This mirrors code done while generating the output map at
// https://github.com/babel/babel/blob/5c2fcadc9ae34fd20dd72b1111d5cf50476d700d/packages/babel-generator/src/source-map.ts#L102
const source = sourceFileName.replace(/\\/g, "/");

// Prevent an infinite recursion if one of the input map's sources has the
// same resolved path as the input map. In the case, it would keep find the
// input map, then get it's sources which will include a path like the input
Expand Down

0 comments on commit ea1c44e

Please sign in to comment.