npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mdx-content-mapper

v0.0.4

Published

A TypeScript content mapper for MDX content.

Readme

mdx-content-mapper

A TypeScript content mapper for MDX content.

The goal is to eventually merge this into mdx-analyzer to replace @mdx-js/typescript-plugin.

Installation

npm install mdx-content-mapper

Usage

After Configuring the content mapper, you can type check your project, including MDX files, using the following command:

tsc --runExternalCode

Configuration

In your tsconfig.json file, add this package to your contentMappers array. Create the contentMappers array if you don’t have it yet.

{
  "compilerOptions": {
    "checkJs": true,
    "jsx": "react-jsx",
    "module": "preserve",
    "noEmit": true,
    "target": "esnext"
    // etc…
  },
  "contentMappers": [
    {
      "package": "mdx-content-mapper",
      "extensions": [".mdx"],
      "options": {
        // Content mapper options go here.
      }
    }
  ]
}

Extensions

The extensions field tells TypeScript which file extensions to let the content mapper handle. Typically you want to add .mdx, but you should also add .md for example if you use the MDX compiler to compile regular Markdown files.

Options

checkCodeBlocks

If enabled, code blocks with the following languages are type checked:

  • cjs
  • cts
  • javascript
  • javascriptreact
  • js
  • json
  • jsonc
  • jsx
  • mjs
  • mts
  • ts
  • tsx
  • typescript
  • typescriptreact

Note that you must enable allowJs or checkJs to allow type checking of JavaScript code blocks.

checkMdx

If you didn’t specify checkJs in your compiler options, you can use this option to enable type checking for MDX content. Note that you need to specify allowJs in the compiler options for this to work.

mdExtensions

The MDX compiler compiles .mdx files to components, but it can also compile regular markdown files. By default it uses the markdown-extensions to determine which file to treat as markdown. You can use the mdExtensions field to override this.

Don’t forget to add any additional extensions you want to check to the extensions field as well.

preset

A preset helps infer MDX props for some popular frameworks. The following presets re supported:

providerImportSource

This option allows you to define an MDX provider import source from which useMDXComponents is imported. This is then used to type check the components you provide to your MDX files. This is resolved relative to your tsconfig.json file.

Next.js supports the mdx-components file. If you have this file, set this option to ./mdx-components or ./src/mdx-components respectively.

If you are using @mdx-js/react, @mdx-js/preact, or @mdx-js/vue, you should ask yourself if you even need this package. If you only use the provider in one place, you don’t. Instead, you can create a file named mdx-components.tsx that exports a function named useMDXComponents:

import { Banner } from './components/banner'
import { Button } from './components/button'
import { Chart } from './components/chart'

const components = {
  Banner,
  Button,
  Chart
} as const

export function useMDXComponents(): typeof components {
  return components
}

Now configure a subpath import in your package.json that points #mdx-components to this file. This will make your bundler and TypeScript understand #mdx-components imports.

{
  "name": "your-app",
  "version": "1.0.0",
  "type": "module",
  "imports": {
    "#mdx-components": "./mdx-components.tsx"
    // Optional additional subpath umports…
  }
  // Rest of package.json…
}

Now set the MDX option providerImportSource to #mdx-components in your bundler configuration, such as vite.config.js or webpack.config.js. Also set this option in the content mapper.

If you must use multiple providers or provide components dynamically in some other way, you can have a look at TypeScript project references.

recmaPlugins

An array of recma plugin names or plugin tuples to use. Currently the only supported plugin is recma-export-filepath

rehypePlugins

An array of rehype plugin names or plugin tuples to use. Currently the only supported plugin is rehype-mdx-title

remarkPlugins

An array of remark plugin names or plugin tuples to use. Currently the only supported transformer plugin is remark-mdx-frontmatter.

Additionally, remark plugins are supported that extend MDX at the parser level. If you use such plugins, you must make sure they are installed in your node_modules. Some popular plugins are:

Compatibility

This project is compatible with TypeScript 7.1 or greater and Node.js 22 or greater.

License

MIT © Remco Haszing