react-loosely-lazy icon indicating copy to clipboard operation
react-loosely-lazy copied to clipboard

Usages regex is not comprehensive enough when types are invovled

Open marcins opened this issue 2 years ago • 0 comments

When updating our codebase to TypeScript we found instances where the usages regex was not comprehensive enough to find all usages. While ideally we would move to an AST based approach, in the meantime @MonicaOlejniczak provided a patch that enhanced the regex to cover more usages.

https://github.com/atlassian-labs/react-loosely-lazy/blob/2a9cbc6954bab02d5c656da09a76d8065e9c5e7b/packages/plugins/parcel-transformer/src/utils.ts#L58-L59

-    const usageStartRe = new RegExp(`${importSpecifier}(?:<.+>)?\\(`);
+    const usageStartRe = new RegExp(`${importSpecifier}(?:<[^>]+[>\s]+)?\\(`);

marcins avatar Jul 26 '22 01:07 marcins