{"_id":"@admirable-oss/mdx-press","name":"@admirable-oss/mdx-press","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@admirable-oss/mdx-press","description":"Compile .mdx straight to Vue components in Rsbuild, with real dev-server HMR.","author":{"name":"Admir Saheta"},"keywords":["rsbuild","rspack","rslib","mdx","markdown","vue","vue-components","hmr","static-site-generator","documentation-tool","mdx-vue","rsbuild-plugin","rspack-plugin"],"repository":{"type":"git","url":"https://github.com/admirable-oss/kyc/packages/mdx-press/README.md"},"version":"0.0.1","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./client":"./client.d.ts"},"types":"./dist/index.d.ts","scripts":{"build":"rslib build && vue-tsc","dev":"rslib build --watch","test":"rstest","test:watch":"rstest --watch"},"dependencies":{"markdown-it":"^15.0.1","markdown-it-anchor":"^10.0.0"},"peerDependencies":{"@rsbuild/core":"^1.0.0 || ^2.0.0","@rsbuild/plugin-vue":"^2.0.0","@rspack/core":"^1.0.0 || ^2.0.0","rspack-vue-loader":"^17.0.0","vue":"^3.2.0"},"devDependencies":{"@rsbuild/core":"^2.2.4","@rsbuild/plugin-vue":"^2.0.1","@rslib/core":"^1.0.0","@rspack/core":"^2.2.3","@rstest/adapter-rslib":"^0.11.10","@rstest/core":"^0.11.10","@types/node":"^24.13.3","rspack-vue-loader":"^17.7.0","typescript":"^6.0.3","vue":"^3.5.42","vue-tsc":"^3.3.11"},"publishConfig":{"access":"public"},"gitHead":"02554944b55d533b01307833604c95b3401de298","_id":"@admirable-oss/mdx-press@0.0.1","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-sgLkSFvbBBHispztQt3+tDeqDKx3dMnUGcQBrANFuG1fEjvEhiX2kHi/6J07RwMImYRLLaIqyGWXeDRsOTh1gA==","shasum":"b3bfe5b2742d4a85e6d182f875512ae2e5116706","tarball":"https://registry.npmjs.org/@admirable-oss/mdx-press/-/mdx-press-0.0.1.tgz","fileCount":14,"unpackedSize":29024,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDeVd/xdXp4EMraYozsmgHC9zN6Yowiu5ex2sn4Tnh31wIgduF0Td6eobu2NGx123MH5/67k1R3gQc9sBnh+uyBVTs="}]},"_npmUser":{"name":"admirable-oss","email":"jobs@admir-saheta.com"},"directories":{},"maintainers":[{"name":"admirable-oss","email":"jobs@admir-saheta.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mdx-press_0.0.1_1789033053585_0.8474061853806791"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-10T09:37:33.369Z","0.0.1":"2026-09-10T09:37:33.727Z","modified":"2026-09-10T09:37:33.902Z"},"maintainers":[{"name":"admirable-oss","email":"jobs@admir-saheta.com"}],"description":"Compile .mdx straight to Vue components in Rsbuild, with real dev-server HMR.","keywords":["rsbuild","rspack","rslib","mdx","markdown","vue","vue-components","hmr","static-site-generator","documentation-tool","mdx-vue","rsbuild-plugin","rspack-plugin"],"repository":{"type":"git","url":"https://github.com/admirable-oss/kyc/packages/mdx-press/README.md"},"author":{"name":"Admir Saheta"},"readme":"<p align=\"center\">\n  <img src=\"https://i.imgur.com/SlZD85b.png\" alt=\"admirable.mdx-press\" width=\"100%\" />\n</p>\n\n# MDXPress\n\n  <a href=\"https://github.com/admirable-oss/kyc\"><img src=\"docs/badge-admirable.svg\"   alt=\"admirable version\" /></a>\n    <a href=\"https://github.com/admirable-oss/kyc\"><img src=\"docs/badge-licence.svg\"   alt=\"licence version\" /></a>\n      <a href=\"https://github.com/admirable-oss/kyc\"><img src=\"docs/badge-public.svg\"   alt=\"admirable version\" /></a>\n\nA native Rspack/Rsbuild plugin that compiles `.mdx` files directly into Vue components, with blazing-fast native performance and built-in dev-server HMR — edit a `.mdx` file and see your changes update instantly, just like any other component in your project.\n\nBuilt for and used by [`admirable-oss/kyc`](https://github.com/admirable-oss/kyc)'s design-system app (`apps/identity`), and published as its own package because the problem it solves — content-authored-separately-from-code that still hot-reloads — isn't specific to that app.\n\n## Why this exists\n\nThe obvious tool for \"MDX in a bundler\" is [`unplugin-vue-markdown`](https://github.com/unplugin/unplugin-vue-markdown) or `@mdx-js/loader`. Both were tried here first and didn't work with Rsbuild's Vue toolchain (`rspack-vue-loader`, a different implementation than webpack's `vue-loader`) — a separately-registered rspack plugin injecting its own module rule has no ordering guarantee against `@rsbuild/plugin-vue`'s own rule for the same file, so the markdown transform silently never ran.\n\nmdx-press takes a narrower, more direct approach: one loader, chained into the **same** module rule as `rspack-vue-loader`, with a documented, deterministic execution order. No unplugin abstraction layer, no separate plugin registration to race against.\n\n## What you get\n\n- `.mdx` files compile to real Vue components — no `v-html`, no runtime markdown parsing in the browser.\n- Each compiled component has two static named exports: `headings` (an `{ id, level, text }[]` outline of its `h2`/`h3`s) and `frontmatter` (its `---` YAML block, flat string fields only).\n- Real HMR, inherited from `rspack-vue-loader` itself — not a custom dev-server hack.\n- One runtime dependency tree: `markdown-it` + `markdown-it-anchor`. No MDX/JSX compiler, no Babel.\n\n## Install\n\n```bash\npnpm add @admirable-oss/mdx-press\n```\n\nRequires `@rsbuild/plugin-vue` to already be configured in your project — mdx-press relies on the `VueLoaderPlugin` it registers and doesn't register a second one.\n\n## Setup\n\n```ts\n// rsbuild.config.ts\nimport { pluginMdxPress } from \"@admirable-oss/mdx-press\";\nimport { defineConfig } from \"@rsbuild/core\";\nimport { pluginVue } from \"@rsbuild/plugin-vue\";\n\nexport default defineConfig({\n  plugins: [\n    pluginVue(),\n    pluginMdxPress({\n      // Optional: Tailwind (or any) utility classes injected onto generated\n      // tags — there's no Vue template to put class= on markdown-generated\n      // HTML, so this is how you theme it.\n      classes: {\n        h2: \"text-2xl font-bold\",\n        h3: \"text-lg font-semibold\",\n        paragraph: \"leading-relaxed\",\n        list: \"list-disc pl-5\",\n        inlineCode: \"rounded bg-gray-100 px-1.5 py-0.5 font-mono\",\n      },\n    }),\n  ],\n});\n```\n\nAdd the ambient module declaration so TypeScript knows what importing a `.mdx` file gives you:\n\n```json\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"types\": [\"@admirable-oss/mdx-press/client\"]\n  }\n}\n```\n\n## Usage\n\nWrite content in `.mdx` — plain markdown, plus raw HTML for anything that needs a visual treatment markdown can't express (styled with the same utility classes as the rest of your app, since it's just HTML):\n\n```mdx\n---\ntitle: Colors\n---\n\n## Foundation\n\n### Colors\n\n<div class=\"grid grid-cols-3 gap-2\">\n<div class=\"rounded border p-2\"><span class=\"block h-8 bg-black\"></span>Ink</div>\n</div>\n```\n\nImport it like any component — `headings`/`frontmatter` come along as named exports:\n\n```vue\n<script setup lang=\"ts\">\nimport Content, { headings, frontmatter } from \"./colors.mdx\";\n</script>\n\n<template>\n  <h1>{{ frontmatter.title }}</h1>\n  <nav>\n    <a v-for=\"h in headings\" :key=\"h.id\" :href=\"`#${h.id}`\">{{ h.text }}</a>\n  </nav>\n  <Content />\n</template>\n```\n\n## What this is *not*\n\nThere's no live-Vue-component-embedding inside the markdown itself (the actual \"MDX\" part of MDX — `<MyComponent />` written directly in the `.md` prose). That's what broke with `unplugin-vue-markdown` + `rspack-vue-loader`. If you need a real component inside a content page today, render it in the Vue file that imports the `.mdx` content, alongside `<Content />` — not inside the markdown source.\n\n`html: true` is on by default in the underlying markdown-it instance — mdx-press assumes first-party-authored content (docs, design-system pages you write yourself), not untrusted/user-submitted markdown. Don't point it at user input.\n\n## API\n\n- `pluginMdxPress(options?)` — the Rsbuild plugin. `options.test` (default `/\\.mdx$/`), `options.classes`, `options.wrapperClass` (default `\"mdx-press\"`, the class on the element wrapping rendered content), `options.vueLoaderOptions` (forwarded to `rspack-vue-loader`).\n- `createMdxParser(classes?)` — the underlying markdown-it wrapper, if you want to parse markdown yourself outside the loader (e.g. in a script, in tests).\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-639905090bf307ac08ac10ff49a0d160"}