refactor(localize): avoid computing source-maps in extraction unnecessarily (#40891)

Previously we were calling `updateSourceLocations()` as part of
`extractMessages()` for every file that was passed in, regardless of
whether any `$localize` tagged strings were to be found in the file.

This was very wasteful because it is non-trivial to compute the flattened
source-map for files if it is not needed.

PR Close #40891
This commit is contained in:
Pete Bacon Darwin 2021-02-17 20:45:56 +00:00 committed by Zach Arend
parent bafab6de79
commit f57cd19e0c
1 changed files with 3 additions and 3 deletions

View File

@ -58,10 +58,10 @@ export class MessageExtractor {
code: false,
ast: false
});
}
if (this.useSourceMaps) {
if (this.useSourceMaps && messages.length > 0) {
this.updateSourceLocations(filename, sourceCode, messages);
}
}
return messages;
}