xdm

raw JSON →
3.4.0 verified Fri May 01 auth: no javascript deprecated

xdm is a deprecated MDX compiler (ESM-only, no runtime, source maps, automatic JSX runtime, esbuild and Rollup plugins) that was a rewrite of @mdx-js/mdx. Current stable version 3.4.0. All functionality has been ported to mdx-js/mdx; users should migrate. Key differentiators vs @mdx-js/mdx: no Babel, smaller browser bundle, built-in source maps. Release cadence was sporadic (last release 2022). Not maintained, use mdx-js/mdx instead.

error ERR_REQUIRE_ESM
cause Trying to require() an ESM-only package
fix
Use import { compile } from 'xdm' instead of require.
error Error: Cannot find module 'xdm'
cause Package not installed
fix
Run npm install xdm. However, consider using mdx-js/mdx instead.
error TypeError: compile is not a function
cause Incorrect import (e.g., default vs named)
fix
Use import { compile } from 'xdm' (named export).
deprecated xdm is deprecated. All features have been ported to mdx-js/mdx. Use mdx-js/mdx instead.
fix Migrate to mdx-js/mdx: https://mdxjs.com/
breaking ESM only: Node 12+ required, cannot require() the package.
fix Use import instead of require().
gotcha xdm has no runtime: do NOT use `@mdx-js/react` or similar runtime helpers.
fix xdm compiles to plain JS, no runtime needed.
npm install xdm
yarn add xdm
pnpm add xdm

Compile an MDX file to JavaScript using the compile() function.

import { compile } from 'xdm'
import { readFile, writeFile } from 'node:fs/promises'

const mdx = await readFile('example.mdx', 'utf8')
const code = await compile(mdx, { jsx: true })
await writeFile('output.js', String(code))

console.log('Compiled successfully')