Registry / serialization / xdm
library3.4.0jsnpmunverified

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.

npm install xdm
INSTALL
IMPORT
SIG · XDM
X
xdm
serializationjavascriptv3.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
✓ import { compile } from 'xdm'
✗ const { compile } = require('xdm')
ESM-only; require() throws Error. Use mdx-js/mdx instead.
run
✓ import { run } from 'xdm'
Added in v3.3.0. Runs compiled MDX in sandbox. Deprecated.
createProcessor
✓ import { createProcessor } from 'xdm'
Low-level processor factory. Used internally. Deprecated.

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')
Debug
Known issues
deprecatedxdm 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/
affects: >=3.0.0
breakingESM only: Node 12+ required, cannot require() the package.
fix
Use import instead of require().
affects: >=2.0.0
gotchaxdm has no runtime: do NOT use `@mdx-js/react` or similar runtime helpers.
fix
xdm compiles to plain JS, no runtime needed.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Trying to require() an ESM-only package
fix
Use import { compile } from 'xdm' instead of require.
Error: Cannot find module 'xdm'
Package not installed
fix
Run `npm install xdm`. However, consider using mdx-js/mdx instead.
TypeError: compile is not a function
Incorrect import (e.g., default vs named)
fix
Use `import { compile } from 'xdm'` (named export).
Upgrade
Version history
3.4.0latest on npm
Audit
Dependencies
@mdx-js/mdxrequiredOfficial replacement; all features ported
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
xdm — npm install xdm · libregistry