Fix importing emoji loader statically inside worker (#38541)
This commit is contained in:
parent
31d2885d95
commit
8e212fca59
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user