From a64cd12d2a963b2cac439c9178a08f1c152d2424 Mon Sep 17 00:00:00 2001 From: larabr <7375870+larabr@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:24:01 +0200 Subject: [PATCH] Revert "Inline jsmimeparser import" This reverts commit d04ba2d5ce8969ccb87d281f7157e59e571c5c22, following implementation of retention of assets from old app versions. --- lib/message/parseMail.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/message/parseMail.ts b/lib/message/parseMail.ts index f56fe344..9e3a53c4 100644 --- a/lib/message/parseMail.ts +++ b/lib/message/parseMail.ts @@ -1,11 +1,11 @@ +// NB: using `export type` is important to ensure we do not import the library unless parseMail (below) is called export type { Attachment } from 'jsmimeparser'; /** * Parse a mail into an object format, splitting, headers, html, text/plain and attachments. - * As jsmime is not a small library, and often unused, we'd nomarlly want to import it dynamically. - * However, due to a web-app deployment issue, we need to inline it for now. + * As jsmime is not a small library, we only want to import it if it's actually used. */ -export { parseMail } from 'jsmimeparser'; +export const parseMail = (mail: string | Uint8Array) => import('jsmimeparser').then(({ parseMail: jsmimeParseEmail }) => jsmimeParseEmail(mail)); // Mapping between mime types to the corresponding extensions. // This is only used if the parsed attachment does not include a filename.