UNPKG

@lingui/cli

Version:

Lingui CLI to extract messages, compile catalogs, and manage translation workflows

13 lines (12 loc) 473 B
export const buildContentFilterRe = (config) => { const macroIds = new Set([ ...config.macro.corePackage, ...config.macro.jsxPackage, ]); // 1. Escape any special regex characters in the IDs (just in case) // 2. Join them with the '|' (OR) operator const macroPattern = Array.from(macroIds) .map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) .join("|"); return new RegExp(`from ['"](?:${macroPattern})['"]`); };