Skip to content

Commit eafa6fc

Browse files
committed
Only modify source map if it's not null
Null checks are why we can't have nice things.
1 parent 3508cad commit eafa6fc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/React.Core/Babel.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,15 @@ protected virtual JavaScriptWithSourceMap TransformWithHeader(
232232
result.Code = header + result.Code;
233233
result.Hash = hash;
234234

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

242245
return result;
243246
}

0 commit comments

Comments
 (0)