Skip to content

Commit 66164c3

Browse files
committed
Add five blank lines to start of source map so the lines match up. Closes #196.
1 parent 0cbbfdc commit 66164c3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/React.Core/Babel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,14 @@ protected virtual JavaScriptWithSourceMap TransformWithHeader(
231231
var header = GetFileHeader(hash);
232232
result.Code = header + result.Code;
233233
result.Hash = hash;
234+
235+
// Since we prepend a header to the code, the source map no longer matches up exactly
236+
// (it's off by the number of lines in the header). Fix this issue by adding five
237+
// blank lines to the source map. This is kinda hacky but saves us having to load a
238+
// proper source map library. If this ever breaks, I'll replace it with actual proper
239+
// source map modification code (https://gist.github.com/Daniel15/4bdb15836bfd960c2956).
240+
result.SourceMap.Mappings = ";;;;;" + result.SourceMap.Mappings;
241+
234242
return result;
235243
}
236244

0 commit comments

Comments
 (0)