Fix jumbo emoji detection broken by production minifier.
Replace surrogate-pair emoji regex with Unicode property escapes so Rolldown no longer corrupts matching in production builds.
This commit is contained in:
@@ -13,13 +13,18 @@ export const findAndReplace = <ReplaceReturnType, ConvertReturnType>(
|
||||
const result: Array<ReplaceReturnType | ConvertReturnType> = [];
|
||||
let lastEnd = 0;
|
||||
|
||||
regex.lastIndex = 0;
|
||||
let match: RegExpExecArray | RegExpMatchArray | null = regex.exec(text);
|
||||
while (match !== null && typeof match.index === 'number') {
|
||||
result.push(convertPart(text.slice(lastEnd, match.index), result.length));
|
||||
result.push(replace(match, result.length));
|
||||
|
||||
lastEnd = match.index + match[0].length;
|
||||
if (match[0].length === 0) {
|
||||
regex.lastIndex += 1;
|
||||
}
|
||||
if (regex.global) match = regex.exec(text);
|
||||
else break;
|
||||
}
|
||||
|
||||
result.push(convertPart(text.slice(lastEnd), result.length));
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user