Rollup plugin for MDX

Downloads in past


14,921122.3.0a month agoa year agoMinified + gzip package size for @mdx-js/rollup in KB


!Buildbuild-badgebuild !Coveragecoverage-badgecoverage !Downloadsdownloads-badgedownloads !Sponsorssponsors-badgecollective !Backersbackers-badgecollective !Chatchat-badgechat
Rollup plugin for MDX.


What is this?

This package is a Rollup plugin to support MDX.

When should I use this?

This integration is useful if you’re using Rollup (or another tool that uses Rollup, such as Vite).
This integration can be combined with the Babel plugin to support nonstandard JSX runtimes (such as Vue) or compile modern JavaScript features to ones your users support.
If you want to evaluate MDX code then the lower-level compiler (@mdx-js/mdx) can be used manually.


This package is ESM onlyesm: Node 12+ is needed to use it and it must be imported instead of required.
npm install @mdx-js/rollup
yarn add @mdx-js/rollup


Add something along these lines to your rollup.config.js:
import mdx from '@mdx-js/rollup'

export default {
  // …
  plugins: [
    // …
    mdx({/* Options… */})

See also ¶ Vitevite and ¶ WMRwmr, if you’re using Rollup through them, for more info.


This package exports a Rollup plugin as the default export.
Source maps are supported based on how you configure Rollup. You do not need to pass options.SourceMapGenerator.
options are the same as compile from @mdx-js/mdxoptions, with the additions of:
List of picomatchpico patterns to include and/or exclude (string, RegExp, Array<string|RegExp>, default: []).
Note: Babel
If you use modern JavaScript features you might want to use Babel through @rollup/plugin-babelrollup-plugin-babel to compile to code that works:
// …
import {babel} from '@rollup/plugin-babel'

export default {
  // …
  plugins: [
    // …
    mdx({/* Options… */}),
      // Also run on what used to be `.mdx` (but is now JS):
      extensions: ['.js', '.jsx', '.cjs', '.mjs', '.md', '.mdx'],
      // Other options…


This package is fully typed with TypeScript. See § Typestypes on our website for information.
An Options type is exported, which represents acceptable configuration.


See § Securitysecurity on our website for information.


See § Contributecontribute on our website for ways to get started. See § Supportsupport for ways to get help.
This project has a code of conductcoc. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Titus Wormerauthor