fix(compiler): support `sourceMappingURL` comments that have trailing lines (#28055)
Previously the call to `extractSourceMap()` would only work if the `//#sourceMappingURL ...` was the last line of the file. This doesn't work if the code is JIT evaluated as the comment is actually the last line in the body of a function, wrapped by curly-braces. PR Close #28055
This commit is contained in:
parent
54ca24b47d
commit
0d6fdec4bd
|
@ -29,7 +29,7 @@ export function originalPositionFor(
|
||||||
export function extractSourceMap(source: string): SourceMap|null {
|
export function extractSourceMap(source: string): SourceMap|null {
|
||||||
let idx = source.lastIndexOf('\n//#');
|
let idx = source.lastIndexOf('\n//#');
|
||||||
if (idx == -1) return null;
|
if (idx == -1) return null;
|
||||||
const smComment = source.slice(idx).trim();
|
const smComment = source.slice(idx).split('\n', 2)[1].trim();
|
||||||
const smB64 = smComment.split('sourceMappingURL=data:application/json;base64,')[1];
|
const smB64 = smComment.split('sourceMappingURL=data:application/json;base64,')[1];
|
||||||
return smB64 ? JSON.parse(decodeB64String(smB64)) : null;
|
return smB64 ? JSON.parse(decodeB64String(smB64)) : null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue