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

View File

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