From 4384e6ccd5864eca7e3dff9f701faeb64f729652 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Thu, 6 Oct 2022 20:45:03 -0400 Subject: [PATCH] Dynamically import micromark --- functions/src/create-comment.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/src/create-comment.ts b/functions/src/create-comment.ts index 564805dc..f0f365c7 100644 --- a/functions/src/create-comment.ts +++ b/functions/src/create-comment.ts @@ -6,7 +6,6 @@ import { JSONContent } from '@tiptap/core' import { z } from 'zod' import { removeUndefinedProps } from '../../common/util/object' import { htmlToRichText } from '../../common/util/parse' -import { micromark } from 'micromark' const contentSchema: z.ZodType = z.lazy(() => z.intersection( @@ -59,9 +58,11 @@ export const createcomment = newEndpoint({}, async (req, auth) => { let contentJson = null if (content) { contentJson = content - } else if (html && !content) { + } else if (html) { contentJson = htmlToRichText(html) - } else if (markdown && !content) { + } else if (markdown) { + // Dynamic import, since micromark doesn't support CommonJS require() + const { micromark } = await import('micromark') contentJson = htmlToRichText(micromark(markdown)) }