Version 1.0.0
@stackline/remark-mdx
remark plugin to support MDX syntax
Independent maintenance of remark-mdx 2.0.0. Original authors and licenses are retained.
Installation
# Preserve existing imports with an npm alias
npm install remark-mdx@npm:@stackline/remark-mdx@1.0.0
# Or use the scoped package name in your imports
npm install @stackline/remark-mdx@1.0.0Node.js: See compatibility notes. Read the compatibility and maintenance notes before migrating.
Usage and API
The reference below may retain upstream package names. Use the alias installation above to run those imports with this Stackline release.
@stackline/remark-mdx
Independent maintenance fork of remark-mdx@2.0.0, preserving its API and published type declarations.
npm install @stackline/remark-mdx
# Keep existing imports:
npm install remark-mdx@npm:@stackline/remark-mdx@1.0.0
Stackline · Issues · Community
See UPSTREAM.md for source identity and issue review, and CHANGELOG.md for maintenance changes. Functional tests also run against the final npm tarball; releases are published from GitHub Actions with provenance.
Upstream documentation
remark-mdx
remark plugin to support the MDX syntax (JSX, expressions, import/exports).
Contents
- What is this?
- When should I use this?
- Install
- Use
- API
- Syntax
- Syntax tree
- Types
- Security
- Contribute
- License
What is this?
This package is a remark plugin to support the MDX syntax.
When should I use this?
This plugin is useful if you’re dealing with the MDX syntax and integrating with remark, rehype, and the rest of unified. Some example use cases are when you want to lint the syntax or compile it to something other that JavaScript.
remark is an AST (abstract syntax tree) based transform project.
The layer under remark is called mdast, which is just the syntax tree without
the convention on how to transform.
mdast is useful when transforming to other formats.
Another layer underneath is micromark, which is just the parser and has support
for concrete tokens.
micromark is useful for linting and formatting.
remark-mdx is a small wrapper to integrate all of these.
Its parts can be used separately.
Typically though, you’d want to move a layer up: @mdx-js/mdx.
That package is the core compiler for turning MDX into JavaScript which
gives you the most control.
Or even higher: if you’re using a bundler (webpack, Rollup, esbuild), or a site
builder (Gatsby, Next.js) or build system (Vite, WMR) which comes with a
bundler, you’re better off using an integration: see
§ Integrations.
Install
This package is ESM only:
Node 12+ is needed to use it and it must be imported instead of required.
npm:
npm install remark-mdx
yarn:
yarn add remark-mdx
Use
import {remark} from 'remark'
import remarkMdx from 'remark-mdx'
const file = remark()
.use(remarkMdx)
.processSync('import a from "b"\n\na <b /> c {1 + 1} d')
console.log(String(file))
Yields:
import a from "b"
a <b/> c {1 + 1} d
API
This package exports no identifiers.
The default export is remarkMdx.
unified().use(remarkMdx)
Configures remark so that it can parse and serialize MDX (JSX, expressions, import/exports). It doesn’t do anything with the syntax: you can create your own plugin to transform them.
Syntax
This plugin applies several micromark extensions to parse the syntax. See their readmes for parse details:
micromark-extension-mdx-expression— expressions ({1 + 1})micromark-extension-mdx-jsx— JSX (<div />)micromark-extension-mdxjs-esm— ESM (export x from 'y')micromark-extension-mdx-md— Turn off HTML, autolinks, and indented code
Syntax tree
This plugin applies several mdast utilities to build and serialize the AST. See their readmes for the node types supported in the tree:
mdast-util-mdx-expression— expressions ({1 + 1})mdast-util-mdx-jsx— JSX (<div />)mdast-util-mdxjs-esm— ESM (export x from 'y')
Types
This package is fully typed with TypeScript.
If you’re working with the syntax tree, make sure to import this plugin somewhere in your types, as that registers the new node types in the tree.
/**
* @typedef {import('remark-mdx')}
*/
import {visit} from 'unist-util-visit'
export default function myRemarkPlugin() => {
/** @param {import('@types/mdast').Root} tree */
return (tree) => {
visit(tree, (node) => {
// `node` can now be one of the nodes for JSX, expressions, or ESM.
})
}
}
Alternatively, in TypeScript, do:
/// <reference types="remark-mdx" />
import type {Root} from '@types/mdast'
import {visit} from 'unist-util-visit'
export default function myRemarkPlugin() => {
return (tree: Root) => {
visit(tree, (node) => {
// `node` can now be one of the nodes for JSX, expressions, or ESM.
})
}
}
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
Upstream issues and maintenance review
Upstream and maintenance review
Independent maintenance of remark-mdx@2.0.0 as @stackline/remark-mdx.
- Source history: https://github.com/mdx-js/mdx/tree/490da9f41e29570d020d3339a842627d6c849e37
- Original npm integrity:
sha512-TDnjSv77Oynf+K1deGWZPKSwh3/9hykVAxVm9enAw6BmicCGklREET8s19KYnjGsNPms0pNDJLmp+bnHDVItAQ==. - Issues checked: 2026-09-29T00:21:59.781247+00:00.
- Original authors, notices and license are retained. Published runtime and declaration file hashes are recorded in
.stackline/upstream.json; reviewed differences are explicitly listed there. - Original functional suites run against both source and the extracted final tarball. Type checks and the complete development/runtime audit must pass.
This maintenance branch selects the npm package from the upstream monorepo into the repository root and retains the upstream Git history. Shared tests are narrowed to this package and wired to its local implementation. Other monorepo products are not published by this repository.
The npm gitHead points to an older prerelease. The 2.0.0 tag was used instead and every published runtime JavaScript file was compared byte-for-byte before preparing this branch.
Issue triage
- https://github.com/mdx-js/mdx/issues/1619: Monorepo dependency dashboard. The isolated package retains only the dependencies and development tools needed for its parser and validation.
- https://github.com/mdx-js/mdx/issues/2653: Expression whitespace semantics require coordinated syntax/compiler design. Existing parsing is preserved; this release does not claim to remove newline children.
- https://github.com/mdx-js/mdx/issues/2621: Future ECMAScript syntax proposal requiring parser and compiler support. Not introduced in this compatibility release.
- https://github.com/mdx-js/mdx/issues/2612: Image-alt expression handling is an existing syntax-extension limitation. No change to the MDX expression grammar is claimed in this release.
- https://github.com/mdx-js/mdx/issues/2606: Concerns the separate MDX compiler/evaluate runtime. This package provides a remark syntax plugin, not that evaluation runtime.
- https://github.com/mdx-js/mdx/issues/2536: New import/export syntax support requires coordinated parser/compiler changes. Not introduced in this compatibility release.
- https://github.com/mdx-js/mdx/issues/2444: Concerns React/Vite HMR in MDX 3. This package is the compatible remark-mdx 2 syntax plugin and has no HMR runtime.
- https://github.com/mdx-js/mdx/issues/454: RFC for multiple MDX documents in one file; feature proposal, not introduced here.
An additional reproduced TypeScript defect was fixed: the public Options alias now imports its defining package directly, avoiding a broken nested node_modules path in micromark-extension-mdxjs declarations. Valid and invalid options are compile-checked. Runtime code is unchanged.
The evidence query fetched the latest 100 open and 30 closed issue/PR entries and removed PRs. This is a bounded review, not a claim of exhaustive issue history or resolution of every issue.
Release verification
GitHub Actions publishes the reviewed passing-CI tarball. Release completion requires exact source identity, zero open CodeQL alerts, npm provenance and tarball identity, normal and aliased installs, and matching immutable GitHub release assets. Existing versions are never replaced.
Release changes
Changelog
1.0.0
- Start Stackline maintenance of the documented upstream API.
- Preserve and verify published runtime files and TypeScript declarations.
- Run upstream functional suites against both source and the final package.
- Publish the reviewed CI artifact through GitHub Actions with provenance and immutable release evidence.
- Fix public option type resolution without relying on a dependency’s invalid nested node_modules declaration path; parser runtime is unchanged.
Release files and references
Package bytes, npm provenance and the immutable GitHub release were verified for this version. Security checks describe the reviewed release; documented compatibility risks and upstream reports are not blanket claims of resolution.