Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import emoji-mart dynamically like (#950) #1491

Merged
merged 3 commits into from
Mar 5, 2025

Conversation

nperez0111
Copy link
Contributor

This resolves the emoji-mart import dynamically just like what was done in #950 to resolve the same issue.

Copy link

vercel bot commented Mar 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Mar 5, 2025 3:57pm
blocknote-website ✅ Ready (Inspect) Visit Preview Mar 5, 2025 3:57pm

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice. I think we might want to also copy or reuse the pattern for loading the data. My guess is that it'll now it from a cdn, better to keep it isolated so we limit external dependencies

let emojiMart: typeof import("emoji-mart") | undefined;
let emojiData: EmojiMartData | undefined;

async function loadEmojiMart() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to make both of these the same, and also made them Node.js safe

? (emojiDataModule.default as EmojiMartData)
: (emojiDataModule as EmojiMartData);

emojiMart.init({ data: emojiData });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs an await

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, wasn't clear that it was async in the docs https://github.com/missive/emoji-mart?tab=readme-ov-file#-emoji-component , but won't hurt to await

}>
| undefined;

// Temporary fix for https://github.com/missive/emoji-mart/pull/929
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, the reason data was global and could be a promise would be to prevent duplicate loads when loadEmojiMart is called twice in a row.

Didn't help readability and it might be a premature optimization so I'm ok with the new version as long as we don't see this causing any issues

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I can de-dupe easily. I'll pull that in.

@nperez0111 nperez0111 merged commit eb52684 into main Mar 5, 2025
6 of 7 checks passed
@nperez0111 nperez0111 deleted the dynamic-import-emoji-mart branch March 5, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants