Add bailout case to sourcemap searching code (#25212)

* Add bailout case to sourcemap searching code

* Also skip sourcemappy comments like sourceURL
This commit is contained in:
Wesley Wigham 2018-06-28 11:40:31 -07:00 committed by GitHub
parent 3a023ed7d6
commit 297f12e92c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 583721 additions and 4 deletions

View File

@ -1510,7 +1510,8 @@ namespace ts {
}
// Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M])
const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/gm;
const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/;
const whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
const base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/;
function scanForSourcemapURL(fileName: string) {
const mappedFile = sourcemappedFileCache.get(toPath(fileName, currentDirectory, getCanonicalFileName));
@ -1519,11 +1520,15 @@ namespace ts {
}
const starts = getLineStarts(mappedFile);
for (let index = starts.length - 1; index >= 0; index--) {
sourceMapCommentRegExp.lastIndex = starts[index];
const comment = sourceMapCommentRegExp.exec(mappedFile.text);
const lineText = mappedFile.text.substring(starts[index], starts[index + 1]);
const comment = sourceMapCommentRegExp.exec(lineText);
if (comment) {
return comment[1];
}
// If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file
else if (!lineText.match(whitespaceOrMapCommentRegExp)) {
break;
}
}
}

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 6b9706810b55af326a93b9aa59cb17815a30bb32
Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6