diff --git a/.oxlintrc.json b/.oxlintrc.json index 349f3eea59..efc7169778 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -78,6 +78,16 @@ "error", { "paths": [ + { + "name": "@emoji-mart/data", + "message": "The emoji dataset is ~500KB; a static import pulls it into the initial bundle. Import the types only and load the data with loadEmojiIndex() from shared/utils/emoji, or loadEmojiData() from shared/editor/lib/emoji.", + "allowTypeImports": true + }, + { + "name": "emoji-mart", + "message": "emoji-mart shares a chunk with the ~500KB emoji dataset. Load it with loadEmojiIndex() from shared/utils/emoji instead of importing it statically.", + "allowTypeImports": true + }, { "name": "prosemirror-tables", "importNames": [ diff --git a/app/.oxlintrc.json b/app/.oxlintrc.json index c5e7a685e1..331bcdcc59 100644 --- a/app/.oxlintrc.json +++ b/app/.oxlintrc.json @@ -16,6 +16,18 @@ "no-restricted-imports": [ "error", { + "paths": [ + { + "name": "@emoji-mart/data", + "message": "The emoji dataset is ~500KB; a static import pulls it into the initial bundle. Import the types only and load the data with loadEmojiIndex() from shared/utils/emoji, or loadEmojiData() from shared/editor/lib/emoji.", + "allowTypeImports": true + }, + { + "name": "emoji-mart", + "message": "emoji-mart shares a chunk with the ~500KB emoji dataset. Load it with loadEmojiIndex() from shared/utils/emoji instead of importing it statically.", + "allowTypeImports": true + } + ], "patterns": [ { "group": ["mime-types"], diff --git a/shared/.oxlintrc.json b/shared/.oxlintrc.json index d42a6acdf0..218f7fbaef 100644 --- a/shared/.oxlintrc.json +++ b/shared/.oxlintrc.json @@ -16,6 +16,18 @@ "no-restricted-imports": [ "error", { + "paths": [ + { + "name": "@emoji-mart/data", + "message": "The emoji dataset is ~500KB; a static import pulls it into the initial bundle. Import the types only and load the data with loadEmojiIndex() from shared/utils/emoji, or loadEmojiData() from shared/editor/lib/emoji.", + "allowTypeImports": true + }, + { + "name": "emoji-mart", + "message": "emoji-mart shares a chunk with the ~500KB emoji dataset. Load it with loadEmojiIndex() from shared/utils/emoji instead of importing it statically.", + "allowTypeImports": true + } + ], "patterns": [ { "group": ["@shared/*"], diff --git a/shared/editor/lib/emoji.ts b/shared/editor/lib/emoji.ts index 421d3d6099..231dd85d57 100644 --- a/shared/editor/lib/emoji.ts +++ b/shared/editor/lib/emoji.ts @@ -53,6 +53,8 @@ export function populateEmojiData(data: EmojiMartData): void { * @returns the raw emoji dataset. */ export function loadEmojiData(): Promise { + // This is the one sanctioned place the dataset is pulled in on the client. + // oxlint-disable-next-line no-restricted-imports dataPromise ??= import("@emoji-mart/data").then(({ default: data }) => { populateEmojiData(data as EmojiMartData); return data as EmojiMartData; diff --git a/shared/utils/emoji.ts b/shared/utils/emoji.ts index 302f9c9450..2d1935fc33 100644 --- a/shared/utils/emoji.ts +++ b/shared/utils/emoji.ts @@ -190,6 +190,7 @@ export function loadEmojiIndex(): Promise { loading ??= (async () => { const [data, emojiMart] = await Promise.all([ loadEmojiData(), + // oxlint-disable-next-line no-restricted-imports import("emoji-mart"), ]); await emojiMart.init({ data });