Skip to content

Commit

Permalink
Only modify source map if it's not null
Browse files Browse the repository at this point in the history
Null checks are why we can't have nice things.
  • Loading branch information
Daniel15 committed Nov 30, 2015
1 parent 3508cad commit eafa6fc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/React.Core/Babel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,15 @@ protected virtual JavaScriptWithSourceMap TransformWithHeader(
result.Code = header + result.Code;
result.Hash = hash;

// Since we prepend a header to the code, the source map no longer matches up exactly
// (it's off by the number of lines in the header). Fix this issue by adding five
// blank lines to the source map. This is kinda hacky but saves us having to load a
// proper source map library. If this ever breaks, I'll replace it with actual proper
// source map modification code (https://gist.github.com/Daniel15/4bdb15836bfd960c2956).
result.SourceMap.Mappings = ";;;;;" + result.SourceMap.Mappings;
if (result.SourceMap != null && result.SourceMap.Mappings != null)
{
// Since we prepend a header to the code, the source map no longer matches up exactly
// (it's off by the number of lines in the header). Fix this issue by adding five
// blank lines to the source map. This is kinda hacky but saves us having to load a
// proper source map library. If this ever breaks, I'll replace it with actual proper
// source map modification code (https://gist.github.com/Daniel15/4bdb15836bfd960c2956).
result.SourceMap.Mappings = ";;;;;" + result.SourceMap.Mappings;
}

return result;
}
Expand Down

0 comments on commit eafa6fc

Please sign in to comment.