Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix merging sourcemaps on Windows #14282

Merged
merged 1 commit into from Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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