From 92d09f7b29378524a8aa7f055bf81a2f624fc586 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 17 Nov 2023 09:36:54 -0700 Subject: [PATCH] fix: dynamic import of esm module --- src/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 293009a..f269212 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,6 @@ import fs from 'fs' import path from 'path' import {StringDecoder} from 'string_decoder' -import remarkMdxFrontmatter from 'remark-mdx-frontmatter' import grayMatter from 'gray-matter' import * as esbuild from 'esbuild' import {NodeResolvePlugin} from '@esbuild-plugins/node-resolve' @@ -38,8 +37,15 @@ async function bundleMDX({ // @mdx-js/esbuild is a native ESM, and we're running in a CJS context. This is the // only way to import ESM within CJS - const [{default: mdxESBuild}, {default: remarkFrontmatter}] = - await Promise.all([import('@mdx-js/esbuild'), import('remark-frontmatter')]) + const [ + {default: mdxESBuild}, + {default: remarkFrontmatter}, + {default: remarkMdxFrontmatter}, + ] = await Promise.all([ + import('@mdx-js/esbuild'), + import('remark-frontmatter'), + import('remark-mdx-frontmatter'), + ]) let /** @type string */ code, /** @type string */ entryPath,