Skip to content

Commit 92d09f7

Browse files
committed
fix: dynamic import of esm module
1 parent 78ce657 commit 92d09f7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import fs from 'fs'
22
import path from 'path'
33
import {StringDecoder} from 'string_decoder'
4-
import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
54
import grayMatter from 'gray-matter'
65
import * as esbuild from 'esbuild'
76
import {NodeResolvePlugin} from '@esbuild-plugins/node-resolve'
@@ -38,8 +37,15 @@ async function bundleMDX({
3837

3938
// @mdx-js/esbuild is a native ESM, and we're running in a CJS context. This is the
4039
// only way to import ESM within CJS
41-
const [{default: mdxESBuild}, {default: remarkFrontmatter}] =
42-
await Promise.all([import('@mdx-js/esbuild'), import('remark-frontmatter')])
40+
const [
41+
{default: mdxESBuild},
42+
{default: remarkFrontmatter},
43+
{default: remarkMdxFrontmatter},
44+
] = await Promise.all([
45+
import('@mdx-js/esbuild'),
46+
import('remark-frontmatter'),
47+
import('remark-mdx-frontmatter'),
48+
])
4349

4450
let /** @type string */ code,
4551
/** @type string */ entryPath,

0 commit comments

Comments
 (0)