Skip to navigation
2-3 minutes read

@mdx-js/esbuild

esbuild plugin for MDX.

Contents

What is this?

This package is an esbuild plugin to support MDX.

When should I use this?

This integration is useful if you’re using esbuild (or another tool that uses esbuild).

If you want to evaluate MDX code then the lower-level compiler (@mdx-js/mdx) can be used. to support nonstandard JSX runtime (such as Vue), @mdx-js/mdx can also be used, or our webpack loader (@mdx-js/loader) or Rollup plugin (@mdx-js/rollup).

Install

This package is ESM only. In Node.js (version 16+), install with npm:

Shell
npm install @mdx-js/esbuild-mdx

Use

Do something like this with the esbuild API:

TypeScript
import mdx from '@mdx-js/esbuild'
import esbuild from 'esbuild'

await esbuild.build({
  // Replace `index.js` with your entry point that imports MDX files:
  entryPoints: ['index.js'],
  format: 'esm',
  outfile: 'output.js',
  plugins: [mdx({/* jsxImportSource: …, otherOptions… */})]
})

API

This package exports no identifiers. The default export is mdx.

mdx(options?)

Create an esbuild plugin to compile MDX to JS.

esbuild takes care of turning modern JavaScript features into syntax that works wherever you want it to. With other integrations you might need to use Babel for this, but with esbuild that’s not needed. See esbuild’s docs for more info.

Parameters
  • options (Options, optional) — configuration
Returns

ESBuild plugin (Plugin from esbuild).

Options

Configuration (TypeScript type).

Options are the same as CompileOptions from @mdx-js/mdx.

Types

This package is fully typed with TypeScript. It exports the additional type Options. See § Types on our website for information.

Compatibility

Projects maintained by the unified collective are compatible with maintained versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, @mdx-js/esbuild@^3, compatible with Node.js 16.

Security

See § Security on our website for information.

Contribute

See § Contribute on our website for ways to get started. See § Support for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer