From 8af0db82a762bf797d0b708833be1b9dc8754ee5 Mon Sep 17 00:00:00 2001 From: Andrew Holloway Date: Thu, 7 Sep 2023 10:38:06 -0500 Subject: [PATCH] fix(Avatar): add fallback workaround to graphemer import class --- src/components/Avatar/Avatar.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/Avatar/Avatar.tsx b/src/components/Avatar/Avatar.tsx index 5c4d89186..5cedef833 100644 --- a/src/components/Avatar/Avatar.tsx +++ b/src/components/Avatar/Avatar.tsx @@ -55,12 +55,14 @@ export interface Props { */ variant?: 'icon' | 'initials' | 'image'; } - /** * Use graphemer to take a name part, and select the first grapheme (emoji, surrogate pair, ASCII character) */ function produceAbbreviation(fromName: string): string { - const splitter = new Graphemer(); + // @see https://github.com/flmnt/graphemer/issues/11 + // @ts-expect-error handles case where this library adds .default to the export inappropriately in CJS context + const G = Graphemer['default'] ? Graphemer.default : Graphemer; + const splitter = new G(); return fromName ? splitter.splitGraphemes(fromName)[0] : '?'; }