Fix importing emoji loader statically inside worker (#38541)

This commit is contained in:
Echo 2026-04-07 15:17:07 +02:00 committed by GitHub
parent 31d2885d95
commit 8e212fca59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -302,7 +302,8 @@ async function toLoadedLocale(localeString: string) {
}
if (!loadedLocales.has(locale)) {
log('Locale %s not loaded, importing...', locale);
const { importEmojiData } = await import('./loader');
// Ignore the INEFFECTIVE_DYNAMIC_IMPORT Vite warning, since the static import location is inside an inlined web worker.
const { importEmojiData } = await import(/* @vite-ignore */ './loader');
await importEmojiData(locale);
return locale;
}

View File

@ -1,4 +1,9 @@
import { EMOJI_DB_NAME_SHORTCODES, EMOJI_TYPE_CUSTOM } from './constants';
import {
importCustomEmojiData,
importEmojiData,
importLegacyShortcodes,
} from './loader';
addEventListener('message', handleMessage);
self.postMessage('ready'); // After the worker is ready, notify the main thread
@ -11,8 +16,6 @@ function handleMessage(event: MessageEvent<{ locale: string }>) {
}
async function loadData(locale: string) {
const { importCustomEmojiData, importEmojiData, importLegacyShortcodes } =
await import('./loader');
let importCount: number | undefined;
if (locale === EMOJI_TYPE_CUSTOM) {
importCount = (await importCustomEmojiData())?.length;