bundleMDX() fails with vanilla MDX
andrecasal opened this issue · 0 comments
andrecasal commented
mdx-bundler
version: 9.2.1node
version: 18.2.0npm
version: 9.7.2
Relevant code or config
import { Container } from '~/components/ui/container.tsx'
import { json } from '@remix-run/node'
/* import { useLoaderData } from '@remix-run/react'
import { useMemo } from 'react' */
import { bundleMDX } from 'mdx-bundler'
/* import { getMDXComponent } from 'mdx-bundler/client' */
export const loader = async () => {
const source = `---
title: Example Post
published: 2021-02-13
description: This is some description
---
# Wahoo
Here's a **neat** demo.`.trim()
const { code, frontmatter } = await bundleMDX({ source })
return json({})
}
const TestingMDX = () => {
//const { code, frontmatter } = useLoaderData<typeof loader>()
// it's generally a good idea to memoize this function call to
// avoid re-creating the component every render.
//const Component = useMemo(() => getMDXComponent(code), [code])
return (
<Container>
<p>Hello world!</p>
<header>
{/* <h1>{frontmatter.title}</h1>
<p>{frontmatter.description}</p> */}
</header>
<main>{/* <Component /> */}</main>
</Container>
)
}
export default TestingMDX
What I did:
- Followed instructions to install mdx-bundler and esbuild
- Added server deps:
serverDependenciesToBundle: ['mdx-bundler', 'mdx-bundler/client'],
What happened:
- bundleMDX() errors with:
Things I've tried:
- Tried adding
esbuild
to server deps but it doesn't seem related to that.